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/diffiter.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests-clar/diff/diffiter.c') diff --git a/tests-clar/diff/diffiter.c b/tests-clar/diff/diffiter.c index 9e33d91e1..4273b16dd 100644 --- a/tests-clar/diff/diffiter.c +++ b/tests-clar/diff/diffiter.c @@ -256,21 +256,23 @@ void test_diff_diffiter__iterate_all(void) cl_assert_equal_i(13, exp.files); cl_assert_equal_i(8, exp.hunks); - cl_assert_equal_i(13, exp.lines); + cl_assert_equal_i(14, exp.lines); git_diff_list_free(diff); } static void iterate_over_patch(git_diff_patch *patch, diff_expects *exp) { - size_t h, num_h = git_diff_patch_num_hunks(patch); + size_t h, num_h = git_diff_patch_num_hunks(patch), num_l; exp->files++; exp->hunks += num_h; /* let's iterate in reverse, just because we can! */ - for (h = 1; h <= num_h; ++h) - exp->lines += git_diff_patch_num_lines_in_hunk(patch, num_h - h); + for (h = 1, num_l = 0; h <= num_h; ++h) + num_l += git_diff_patch_num_lines_in_hunk(patch, num_h - h); + + exp->lines += num_l; } #define PATCH_CACHE 5 @@ -338,5 +340,5 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void) /* hopefully it all still added up right */ cl_assert_equal_i(13, exp.files); cl_assert_equal_i(8, exp.hunks); - cl_assert_equal_i(13, exp.lines); + cl_assert_equal_i(14, exp.lines); } -- cgit v1.2.1