From 642863086575a61b3ed0bbbe909f4f07d87ff9db Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 25 Sep 2012 10:48:50 -0700 Subject: Fix bugs in new diff patch code This fixes all the bugs in the new diff patch code. The only really interesting one is that when we merge two diffs, we now have to actually exclude diff delta records that are not supposed to be tracked, as opposed to before where they could be included because they would be skipped silently by `git_diff_foreach()`. Other than that, there are just minor errors. --- tests-clar/diff/diff_helpers.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index 1c0435975..0c4721897 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -120,7 +120,7 @@ int diff_foreach_via_iterator( size_t h, num_h; cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d)); - cl_assert(delta && patch); + cl_assert(delta); /* call file_cb for this file */ if (file_cb != NULL && file_cb(data, delta, (float)d / num_d) != 0) { @@ -128,6 +128,12 @@ int diff_foreach_via_iterator( goto abort; } + /* if there are no changes, then the patch will be NULL */ + if (!patch) { + cl_assert(delta->status == GIT_DELTA_UNMODIFIED || delta->binary == 1); + continue; + } + if (!hunk_cb && !line_cb) { git_diff_patch_free(patch); continue; -- cgit v1.2.1