Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-07-19 01:19:10 +0400
committerEdward Thomson <ethomson@microsoft.com>2014-10-27 05:59:25 +0300
commit517644cce4df8ac9ea40669dd22574d6dc76c02f (patch)
tree42b7db6d75da4dd1ccc6cee45c670bf47504d0b4 /tests/rebase
parent14864fbfebfd3eb949790f302cfd872f1c0cc214 (diff)
Introduce git_rebase_finish to complete a rebase
Diffstat (limited to 'tests/rebase')
-rw-r--r--tests/rebase/merge.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index 31fa6cc5e..fa37e89e6 100644
--- a/tests/rebase/merge.c
+++ b/tests/rebase/merge.c
@@ -295,3 +295,60 @@ void test_rebase_merge__commit_drops_already_applied(void)
git_reference_free(upstream_ref);
}
+void test_rebase_merge__finish(void)
+{
+ git_reference *branch_ref, *upstream_ref, *head_ref;
+ git_merge_head *branch_head, *upstream_head;
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_oid commit_id;
+ git_reflog *reflog;
+ const git_reflog_entry *reflog_entry;
+ int error;
+
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+ cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/gravy"));
+ cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
+
+ cl_git_pass(git_merge_head_from_ref(&branch_head, repo, branch_ref));
+ cl_git_pass(git_merge_head_from_ref(&upstream_head, repo, upstream_ref));
+
+ cl_git_pass(git_rebase(repo, branch_head, upstream_head, NULL, signature, NULL));
+
+ cl_git_pass(git_rebase_next(repo, &checkout_opts));
+ cl_git_pass(git_rebase_commit(&commit_id, repo, NULL, signature,
+ NULL, NULL));
+
+ cl_git_fail(error = git_rebase_next(repo, &checkout_opts));
+ cl_assert_equal_i(GIT_ITEROVER, error);
+
+ cl_git_pass(git_rebase_finish(repo, signature));
+
+ cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
+
+ cl_git_pass(git_reference_lookup(&head_ref, repo, "HEAD"));
+ cl_assert_equal_i(GIT_REF_SYMBOLIC, git_reference_type(head_ref));
+ cl_assert_equal_s("refs/heads/gravy", git_reference_symbolic_target(head_ref));
+
+ /* Make sure the reflogs are updated appropriately */
+ cl_git_pass(git_reflog_read(&reflog, repo, "HEAD"));
+ cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+ cl_assert_equal_oid(&commit_id, git_reflog_entry_id_old(reflog_entry));
+ cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
+ cl_assert_equal_s("rebase finished: returning to refs/heads/gravy", git_reflog_entry_message(reflog_entry));
+ git_reflog_free(reflog);
+
+ cl_git_pass(git_reflog_read(&reflog, repo, "refs/heads/gravy"));
+ cl_assert(reflog_entry = git_reflog_entry_byindex(reflog, 0));
+ cl_assert_equal_oid(git_merge_head_id(branch_head), git_reflog_entry_id_old(reflog_entry));
+ cl_assert_equal_oid(&commit_id, git_reflog_entry_id_new(reflog_entry));
+ cl_assert_equal_s("rebase finished: refs/heads/gravy onto f87d14a4a236582a0278a916340a793714256864", git_reflog_entry_message(reflog_entry));
+
+ git_reflog_free(reflog);
+ git_merge_head_free(branch_head);
+ git_merge_head_free(upstream_head);
+ git_reference_free(head_ref);
+ git_reference_free(branch_ref);
+ git_reference_free(upstream_ref);
+}
+