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/diffiter.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/diffiter.c')
-rw-r--r-- | tests-clar/diff/diffiter.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/tests-clar/diff/diffiter.c b/tests-clar/diff/diffiter.c index 1a1e5dfc3..f886e1baa 100644 --- a/tests-clar/diff/diffiter.c +++ b/tests-clar/diff/diffiter.c @@ -101,15 +101,10 @@ void test_diff_diffiter__iterate_files_and_hunks(void) num_h = git_patch_num_hunks(patch); for (h = 0; h < num_h; h++) { - const git_diff_hunk *range; - const char *header; - size_t header_len, num_l; - - cl_git_pass(git_patch_get_hunk( - &range, &header, &header_len, &num_l, patch, h)); + const git_diff_hunk *hunk; - cl_assert(range); - cl_assert(header); + cl_git_pass(git_patch_get_hunk(&hunk, NULL, patch, h)); + cl_assert(hunk); hunk_count++; } @@ -229,22 +224,17 @@ void test_diff_diffiter__iterate_all(void) num_h = git_patch_num_hunks(patch); for (h = 0; h < num_h; h++) { const git_diff_hunk *range; - const char *header; - size_t header_len, l, num_l; + size_t l, num_l; - cl_git_pass(git_patch_get_hunk( - &range, &header, &header_len, &num_l, patch, h)); - cl_assert(range && header); + cl_git_pass(git_patch_get_hunk(&range, &num_l, patch, h)); + cl_assert(range); exp.hunks++; for (l = 0; l < num_l; ++l) { - char origin; - const char *content; - size_t content_len; + const git_diff_line *line; - cl_git_pass(git_patch_get_line_in_hunk( - &origin, &content, &content_len, NULL, NULL, patch, h, l)); - cl_assert(content); + cl_git_pass(git_patch_get_line_in_hunk(&line, patch, h, l)); + cl_assert(line && line->content); exp.lines++; } } |