summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkgrel.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/pkgrel.c b/pkgrel.c
index a803c39..fe8d072 100644
--- a/pkgrel.c
+++ b/pkgrel.c
@@ -66,6 +66,22 @@ gerror(void)
int
+line_line(const git_diff_delta* delta, const git_diff_hunk* hunk, const git_diff_line* line, void* payload)
+{
+ switch (line->origin) {
+ case GIT_DIFF_LINE_ADDITION:
+ printf("+%.*s", line->content_len, line->content);
+ break;
+ case GIT_DIFF_LINE_DELETION:
+ printf("-%.*s", line->content_len, line->content);
+ break;
+ default:
+ }
+ return 0;
+}
+
+
+int
main(int argc, char* argv[])
{
git_libgit2_init();
@@ -113,12 +129,17 @@ main(int argc, char* argv[])
gerror();
return 1;
}
- const int matched = 0 == git_pathspec_match_tree(NULL, later, GIT_PATHSPEC_NO_MATCH_ERROR, pathspec);
- if (matched) {
- char buf[GIT_OID_HEXSZ + 1];
- git_oid_tostr(buf, sizeof(buf), git_commit_id(commit));
- puts(buf);
+ git_diff* diff;
+ if (NULL == earlier)
+ err = git_diff_tree_to_workdir_with_index(&diff, repo, later, &diffopts);
+ else
+ err = git_diff_tree_to_tree(&diff, repo, later, earlier, &diffopts);
+ if (0 > err) {
+ gerror();
+ return 1;
}
+ git_diff_foreach(diff, NULL, NULL, NULL, &line_line, NULL);
+ git_diff_free(diff);
git_commit_free(commit);
}
if (NULL != earlier)