summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-03-17 17:21:11 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-04-20 16:22:59 -0400
commit7838235890b10e1e3c6ceb2c696c4721ad438246 (patch)
tree840d897f637f8c52f2d84eac52a8515409561d17
parentf3a199dd9952a885621848c82b7b68c78723a9ed (diff)
downloadlibgit2-7838235890b10e1e3c6ceb2c696c4721ad438246.tar.gz
rebase: test checkout options for rebase
-rw-r--r--tests/rebase/merge.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index 7aea4f088..4371f1f1f 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);
+}