diff options
author | Russell Belfer <rb@github.com> | 2014-02-07 14:17:19 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-04-17 14:43:45 -0700 |
commit | 27e54bcf82fe27bdfadbaa9c5383ee8a948ea33c (patch) | |
tree | 9b373c91e459827dda96179ccd77c7ecccdef355 /tests/diff/diff_helpers.c | |
parent | 3dbee456564a9baf24631bfe219f81434d8fdfa6 (diff) | |
download | libgit2-27e54bcf82fe27bdfadbaa9c5383ee8a948ea33c.tar.gz |
Add public diff print helpers
The usefulness of these helpers came up for me while debugging
some of the iterator changes that I was making, so since they
have also been requested (albeit indirectly) I thought I'd include
them.
Diffstat (limited to 'tests/diff/diff_helpers.c')
-rw-r--r-- | tests/diff/diff_helpers.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/tests/diff/diff_helpers.c b/tests/diff/diff_helpers.c index 33bb561f6..279cb20c5 100644 --- a/tests/diff/diff_helpers.c +++ b/tests/diff/diff_helpers.c @@ -1,5 +1,6 @@ #include "clar_libgit2.h" #include "diff_helpers.h" +#include "git2/sys/diff.h" git_tree *resolve_commit_oid_to_tree( git_repository *repo, @@ -215,32 +216,16 @@ abort: return GIT_EUSER; } -static int diff_print_cb( - const git_diff_delta *delta, - const git_diff_hunk *hunk, - const git_diff_line *line, - void *payload) -{ - FILE *fp = payload; - - GIT_UNUSED(delta); GIT_UNUSED(hunk); - - if (line->origin == GIT_DIFF_LINE_CONTEXT || - line->origin == GIT_DIFF_LINE_ADDITION || - line->origin == GIT_DIFF_LINE_DELETION) - fputc(line->origin, fp); - fwrite(line->content, 1, line->content_len, fp); - return 0; -} - void diff_print(FILE *fp, git_diff *diff) { - cl_git_pass(git_diff_print( - diff, GIT_DIFF_FORMAT_PATCH, diff_print_cb, fp ? fp : stderr)); + cl_git_pass( + git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, + git_diff_print_callback__to_file_handle, fp ? fp : stderr)); } void diff_print_raw(FILE *fp, git_diff *diff) { - cl_git_pass(git_diff_print( - diff, GIT_DIFF_FORMAT_RAW, diff_print_cb, fp ? fp : stderr)); + cl_git_pass( + git_diff_print(diff, GIT_DIFF_FORMAT_RAW, + git_diff_print_callback__to_file_handle, fp ? fp : stderr)); } |