rebase: test checkout options for rebase
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index 7aea4f0..4371f1f 100644
--- a/tests/rebase/merge.c
+++ b/tests/rebase/merge.c
@@ -510,3 +510,52 @@ void test_rebase_merge__copy_notes_disabled_in_config(void)
test_copy_note(NULL, 0);
}
+void rebase_checkout_progress_cb(
+ const char *path,
+ size_t completed_steps,
+ size_t total_steps,
+ void *payload)
+{
+ int *called = payload;
+ *called = 1;
+}
+
+void test_rebase_merge__custom_checkout_options(void)
+{
+ git_rebase *rebase;
+ git_reference *branch_ref, *upstream_ref;
+ git_annotated_commit *branch_head, *upstream_head;
+ git_rebase_options rebase_options = GIT_REBASE_OPTIONS_INIT;
+ git_checkout_options checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
+ git_rebase_operation *rebase_operation;
+ int called = 0;
+
+ checkout_options.progress_cb = rebase_checkout_progress_cb;
+ checkout_options.progress_payload = &called;
+
+ rebase_options.checkout_options = &checkout_options;
+
+ cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+ cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
+
+ cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
+ cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
+
+ called = 0;
+ cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, &rebase_options));
+ cl_assert_equal_i(1, called);
+
+ called = 0;
+ cl_git_pass(git_rebase_next(&rebase_operation, rebase));
+ cl_assert_equal_i(1, called);
+
+ called = 0;
+ cl_git_pass(git_rebase_abort(rebase));
+ cl_assert_equal_i(1, called);
+
+ git_annotated_commit_free(branch_head);
+ git_annotated_commit_free(upstream_head);
+ git_reference_free(branch_ref);
+ git_reference_free(upstream_ref);
+ git_rebase_free(rebase);
+}