diff options
author | Russell Belfer <rb@github.com> | 2013-10-21 13:42:42 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-10-21 13:42:42 -0700 |
commit | 3b5f795446601868d52d09ebac70ae3b7aee157a (patch) | |
tree | ba900c737284e65c172fde7284af3f309b0a0078 /tests-clar/diff/blob.c | |
parent | 74a627f04528f7e02f69d8d7947820582ce7ca15 (diff) | |
download | libgit2-3b5f795446601868d52d09ebac70ae3b7aee157a.tar.gz |
Create git_diff_line and extend git_diff_hunk
Instead of having functions with so very many parameters to pass
hunk and line data, this takes the existing git_diff_hunk struct
and extends it with more hunk data, plus adds a git_diff_line.
Those structs are used to pass back hunk and line data instead of
the old APIs that took tons of parameters.
Some work that was previously only being done for git_diff_patch
creation (scanning the diff content for exact line counts) is now
done for all callbacks, but the performance difference should not
be noticable.
Diffstat (limited to 'tests-clar/diff/blob.c')
-rw-r--r-- | tests-clar/diff/blob.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tests-clar/diff/blob.c b/tests-clar/diff/blob.c index 898c037b5..b51bc0f38 100644 --- a/tests-clar/diff/blob.c +++ b/tests-clar/diff/blob.c @@ -319,8 +319,8 @@ void test_diff_blob__can_compare_against_null_blobs_with_patch(void) git_blob *e = NULL; git_patch *p; const git_diff_delta *delta; - int line; - char origin; + const git_diff_line *line; + int l, max_l; cl_git_pass(git_patch_from_blobs(&p, d, NULL, e, NULL, &opts)); @@ -337,10 +337,10 @@ void test_diff_blob__can_compare_against_null_blobs_with_patch(void) cl_assert_equal_i(1, (int)git_patch_num_hunks(p)); cl_assert_equal_i(14, git_patch_num_lines_in_hunk(p, 0)); - for (line = 0; line < git_patch_num_lines_in_hunk(p, 0); ++line) { - cl_git_pass(git_patch_get_line_in_hunk( - &origin, NULL, NULL, NULL, NULL, p, 0, line)); - cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)origin); + max_l = git_patch_num_lines_in_hunk(p, 0); + for (l = 0; l < max_l; ++l) { + cl_git_pass(git_patch_get_line_in_hunk(&line, p, 0, l)); + cl_assert_equal_i(GIT_DIFF_LINE_DELETION, (int)line->origin); } git_patch_free(p); @@ -362,10 +362,10 @@ void test_diff_blob__can_compare_against_null_blobs_with_patch(void) cl_assert_equal_i(1, (int)git_patch_num_hunks(p)); cl_assert_equal_i(14, git_patch_num_lines_in_hunk(p, 0)); - for (line = 0; line < git_patch_num_lines_in_hunk(p, 0); ++line) { - cl_git_pass(git_patch_get_line_in_hunk( - &origin, NULL, NULL, NULL, NULL, p, 0, line)); - cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)origin); + max_l = git_patch_num_lines_in_hunk(p, 0); + for (l = 0; l < max_l; ++l) { + cl_git_pass(git_patch_get_line_in_hunk(&line, p, 0, l)); + cl_assert_equal_i(GIT_DIFF_LINE_ADDITION, (int)line->origin); } git_patch_free(p); |