Commit 7838235890b10e1e3c6ceb2c696c4721ad438246

Edward Thomson 2015-03-17T17:21:11

rebase: test checkout options for rebase

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);
+}