diff options
author | Russell Belfer <rb@github.com> | 2013-10-15 15:10:07 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-10-15 15:10:07 -0700 |
commit | 10672e3e455eba2d4ca983070ed427caeeb24a6f (patch) | |
tree | e812af06091362849e9ecd279c5547e401cb0862 /tests-clar/diff/patch.c | |
parent | 3ff1d123736e5686fb9ec16e65828d5b8ffa2b30 (diff) | |
download | libgit2-10672e3e455eba2d4ca983070ed427caeeb24a6f.tar.gz |
Diff API cleanup
This lays groundwork for separating formatting options from diff
creation options. This groups the formatting flags separately
from the diff list creation flags and reorders the options. This
also tweaks some APIs to further separate code that uses patches
from code that just looks at git_diffs.
Diffstat (limited to 'tests-clar/diff/patch.c')
-rw-r--r-- | tests-clar/diff/patch.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c index e5d8fca9a..9c01c3b4e 100644 --- a/tests-clar/diff/patch.c +++ b/tests-clar/diff/patch.c @@ -95,7 +95,8 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void) cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL)); - cl_git_pass(git_diff_print_patch(diff, check_removal_cb, NULL)); + cl_git_pass(git_diff_print( + diff, GIT_DIFF_FORMAT_PATCH, check_removal_cb, NULL)); git_diff_free(diff); @@ -122,7 +123,7 @@ void test_diff_patch__to_string(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, NULL, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_str(&text, patch)); @@ -167,7 +168,7 @@ void test_diff_patch__config_options(void) cl_git_pass(git_diff_tree_to_index(&diff, g_repo, one, NULL, &opts)); cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, NULL, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_str(&text, patch)); cl_assert_equal_s(expected1, text); @@ -178,7 +179,7 @@ void test_diff_patch__config_options(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, NULL, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_str(&text, patch)); cl_assert_equal_s(expected2, text); @@ -192,7 +193,7 @@ void test_diff_patch__config_options(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, NULL, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_str(&text, patch)); cl_assert_equal_s(expected3, text); @@ -206,7 +207,7 @@ void test_diff_patch__config_options(void) cl_git_pass(git_diff_tree_to_index(&diff, g_repo, one, NULL, &opts)); cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, NULL, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); cl_git_pass(git_patch_to_str(&text, patch)); cl_assert_equal_s(expected4, text); @@ -253,7 +254,8 @@ void test_diff_patch__hunks_have_correct_line_numbers(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, &delta, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_assert((delta = git_patch_get_delta(patch)) != NULL); cl_assert_equal_i(GIT_DELTA_MODIFIED, (int)delta->status); cl_assert_equal_i(2, (int)git_patch_num_hunks(patch)); @@ -346,7 +348,8 @@ void test_diff_patch__hunks_have_correct_line_numbers(void) cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, &delta, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_assert((delta = git_patch_get_delta(patch)) != NULL); cl_assert_equal_i(GIT_DELTA_MODIFIED, (int)delta->status); cl_assert_equal_i(1, (int)git_patch_num_hunks(patch)); @@ -427,7 +430,8 @@ static void check_single_patch_stats( cl_assert_equal_i(1, (int)git_diff_num_deltas(diff)); - cl_git_pass(git_patch_from_diff(&patch, &delta, diff, 0)); + cl_git_pass(git_patch_from_diff(&patch, diff, 0)); + cl_assert((delta = git_patch_get_delta(patch)) != NULL); cl_assert_equal_i(GIT_DELTA_MODIFIED, (int)delta->status); cl_assert_equal_i((int)hunks, (int)git_patch_num_hunks(patch)); |