summaryrefslogtreecommitdiff
path: root/tests-clar/diff/diffiter.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-09-25 10:48:50 -0700
committerRussell Belfer <rb@github.com>2012-09-25 16:35:05 -0700
commit642863086575a61b3ed0bbbe909f4f07d87ff9db (patch)
tree22cb6c0d2355e4a15edd645104b39fe2c33c97ac /tests-clar/diff/diffiter.c
parent5f69a31f7d706aa5788ad9937391577a66e3c77d (diff)
downloadlibgit2-642863086575a61b3ed0bbbe909f4f07d87ff9db.tar.gz
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.
Diffstat (limited to 'tests-clar/diff/diffiter.c')
-rw-r--r--tests-clar/diff/diffiter.c12
1 files changed, 7 insertions, 5 deletions
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);
}