diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-05-26 03:03:59 +0300 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-06-12 16:39:20 +0300 |
commit | 8147b1aff56c0f36f6afee9b8810fc74776e1f58 (patch) | |
tree | 298396fb80a973b990e21084e29b0466ceafe5ed /tests/diff/workdir.c | |
parent | ac7012a81f0bdc472a3d22393291eb7d130705d1 (diff) |
diff: introduce binary diff callbacks
Introduce a new binary diff callback to provide the actual binary
delta contents to callers. Create this data from the diff contents
(instead of directly from the ODB) to support binary diffs including
the workdir, not just things coming out of the ODB.
Diffstat (limited to 'tests/diff/workdir.c')
-rw-r--r-- | tests/diff/workdir.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index 65005f927..5d6ebed95 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -30,10 +30,10 @@ void test_diff_workdir__to_index(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); /* to generate these values: * - cd to tests/resources/status, @@ -94,7 +94,7 @@ void test_diff_workdir__to_index_with_conflicts(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, &opts)); cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(9, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -129,7 +129,7 @@ void test_diff_workdir__to_index_with_assume_unchanged(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(8, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); cl_assert_equal_i(4, exp.file_status[GIT_DELTA_DELETED]); @@ -158,7 +158,7 @@ void test_diff_workdir__to_index_with_assume_unchanged(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(6, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); cl_assert_equal_i(3, exp.file_status[GIT_DELTA_DELETED]); @@ -205,10 +205,10 @@ void test_diff_workdir__to_tree(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(14, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -241,10 +241,10 @@ void test_diff_workdir__to_tree(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(15, exp.files); cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]); @@ -278,10 +278,10 @@ void test_diff_workdir__to_tree(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(16, exp.files); cl_assert_equal_i(5, exp.file_status[GIT_DELTA_ADDED]); @@ -312,7 +312,7 @@ void test_diff_workdir__to_tree(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(16, exp.files); cl_assert_equal_i(5, exp.file_status[GIT_DELTA_DELETED]); @@ -359,9 +359,9 @@ void test_diff_workdir__to_index_with_pathspec(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, NULL, NULL, &exp)); + diff, diff_file_cb, NULL, NULL, NULL, &exp)); else - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(13, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -382,9 +382,9 @@ void test_diff_workdir__to_index_with_pathspec(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, NULL, NULL, &exp)); + diff, diff_file_cb, NULL, NULL, NULL, &exp)); else - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -405,9 +405,9 @@ void test_diff_workdir__to_index_with_pathspec(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, NULL, NULL, &exp)); + diff, diff_file_cb, NULL, NULL, NULL, &exp)); else - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(3, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -428,9 +428,9 @@ void test_diff_workdir__to_index_with_pathspec(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, NULL, NULL, &exp)); + diff, diff_file_cb, NULL, NULL, NULL, &exp)); else - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(2, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -465,10 +465,10 @@ void test_diff_workdir__filemode_changes(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]); @@ -488,10 +488,10 @@ void test_diff_workdir__filemode_changes(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]); @@ -521,7 +521,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]); @@ -536,8 +536,8 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL)); memset(&exp, 0, sizeof(exp)); - cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + cl_git_pass(git_diff_foreach(diff, + diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]); @@ -580,10 +580,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -601,10 +601,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_w2i, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_w2i, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -624,10 +624,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff_i2t, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -666,10 +666,10 @@ void test_diff_workdir__eof_newline_changes(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -693,10 +693,10 @@ void test_diff_workdir__eof_newline_changes(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -720,10 +720,10 @@ void test_diff_workdir__eof_newline_changes(void) if (use_iterator) cl_git_pass(diff_foreach_via_iterator( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); else cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -913,7 +913,7 @@ void test_diff_workdir__submodules(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); /* so "git diff 873585" returns: * M .gitmodules @@ -991,7 +991,7 @@ void test_diff_workdir__to_null_tree(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(exp.files, exp.file_status[GIT_DELTA_UNTRACKED]); @@ -1080,7 +1080,7 @@ void test_diff_workdir__to_index_issue_1397(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.hunks); @@ -1096,7 +1096,7 @@ void test_diff_workdir__to_index_issue_1397(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(1, exp.files); cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]); @@ -1133,7 +1133,7 @@ void test_diff_workdir__to_tree_issue_1397(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.hunks); @@ -1149,7 +1149,7 @@ void test_diff_workdir__to_tree_issue_1397(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(0, exp.files); cl_assert_equal_i(0, exp.hunks); @@ -1203,7 +1203,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(3, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1223,7 +1223,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1243,7 +1243,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1267,7 +1267,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1290,7 +1290,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1310,7 +1310,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1333,7 +1333,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1354,7 +1354,7 @@ void test_diff_workdir__untracked_directory_scenarios(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts)); - cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp)); + cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp)); cl_assert_equal_i(4, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1505,7 +1505,7 @@ void test_diff_workdir__with_stale_index(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(17, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); @@ -1527,7 +1527,7 @@ void test_diff_workdir__with_stale_index(void) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); git_diff_free(diff); @@ -1568,7 +1568,7 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts) memset(&exp, 0, sizeof(exp)); cl_git_pass(git_diff_foreach( - *out, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); + *out, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)); cl_assert_equal_i(13, exp.files); cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]); |