]> git.proxmox.com Git - libgit2.git/blobdiff - tests/diff/notify.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / diff / notify.c
index da7390d3f07153eb076a5e28041d753a3c94e947..653512795b34e5076743cf413a17e78c965dd271 100644 (file)
@@ -55,11 +55,11 @@ static void test_notify(
        opts.pathspec.strings = searched_pathspecs;
        opts.pathspec.count   = pathspecs_count;
 
-       opts.notify_payload = expected_matched_pathspecs;
+       opts.payload = expected_matched_pathspecs;
        memset(&exp, 0, sizeof(exp));
 
        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(expected_diffed_files_count, exp.files);
 
@@ -222,9 +222,37 @@ void test_diff_notify__notify_cb_can_be_used_as_filtering_function(void)
        memset(&exp, 0, sizeof(exp));
 
        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(0, exp.files);
 
        git_diff_free(diff);
 }
+
+static int progress_abort_diff(
+       const git_diff *diff_so_far,
+       const char *old_path,
+       const char *new_path,
+       void *payload)
+{
+       GIT_UNUSED(diff_so_far);
+       GIT_UNUSED(old_path);
+       GIT_UNUSED(new_path);
+       GIT_UNUSED(payload);
+
+       return -42;
+}
+
+void test_diff_notify__progress_cb_can_abort_diff(void)
+{
+       git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+       git_diff *diff = NULL;
+
+       g_repo = cl_git_sandbox_init("status");
+
+       opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
+       opts.progress_cb = progress_abort_diff;
+
+       cl_git_fail_with(
+               git_diff_index_to_workdir(&diff, g_repo, NULL, &opts), -42);
+}