rebase: test abort immediately after init Instead of `open`ing a rebase and `abort`ing that, test that we can `abort` a rebase that has just begun with `init`.
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
diff --git a/tests/rebase/abort.c b/tests/rebase/abort.c
index 4cf14dd..7052952 100644
--- a/tests/rebase/abort.c
+++ b/tests/rebase/abort.c
@@ -19,17 +19,15 @@ void test_rebase_abort__cleanup(void)
cl_git_sandbox_cleanup();
}
-static void test_abort(git_annotated_commit *branch, git_annotated_commit *onto)
+static void ensure_aborted(
+ git_annotated_commit *branch,
+ git_annotated_commit *onto)
{
- git_rebase *rebase;
git_reference *head_ref, *branch_ref = NULL;
git_status_list *statuslist;
git_reflog *reflog;
const git_reflog_entry *reflog_entry;
- cl_git_pass(git_rebase_open(&rebase, repo, NULL));
- cl_git_pass(git_rebase_abort(rebase));
-
cl_assert_equal_i(GIT_REPOSITORY_STATE_NONE, git_repository_state(repo));
/* Make sure the refs are updated appropriately */
@@ -58,6 +56,18 @@ static void test_abort(git_annotated_commit *branch, git_annotated_commit *onto)
git_reflog_free(reflog);
git_reference_free(head_ref);
git_reference_free(branch_ref);
+}
+
+static void test_abort(
+ git_annotated_commit *branch, git_annotated_commit *onto)
+{
+ git_rebase *rebase;
+
+ cl_git_pass(git_rebase_open(&rebase, repo, NULL));
+ cl_git_pass(git_rebase_abort(rebase));
+
+ ensure_aborted(branch, onto);
+
git_rebase_free(rebase);
}
@@ -86,6 +96,32 @@ void test_rebase_abort__merge(void)
git_rebase_free(rebase);
}
+void test_rebase_abort__merge_immediately_after_init(void)
+{
+ git_rebase *rebase;
+ git_reference *branch_ref, *onto_ref;
+ git_annotated_commit *branch_head, *onto_head;
+
+ cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/beef"));
+ cl_git_pass(git_reference_lookup(&onto_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(&onto_head, repo, onto_ref));
+
+ cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
+ cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+ cl_git_pass(git_rebase_abort(rebase));
+ ensure_aborted(branch_head, onto_head);
+
+ git_annotated_commit_free(branch_head);
+ git_annotated_commit_free(onto_head);
+
+ git_reference_free(branch_ref);
+ git_reference_free(onto_ref);
+ git_rebase_free(rebase);
+}
+
void test_rebase_abort__merge_by_id(void)
{
git_rebase *rebase;
@@ -109,6 +145,30 @@ void test_rebase_abort__merge_by_id(void)
git_rebase_free(rebase);
}
+void test_rebase_abort__merge_by_id_immediately_after_init(void)
+{
+ git_rebase *rebase;
+ git_oid branch_id, onto_id;
+ git_annotated_commit *branch_head, *onto_head;
+
+ cl_git_pass(git_oid_fromstr(&branch_id, "b146bd7608eac53d9bf9e1a6963543588b555c64"));
+ cl_git_pass(git_oid_fromstr(&onto_id, "efad0b11c47cb2f0220cbd6f5b0f93bb99064b00"));
+
+ cl_git_pass(git_annotated_commit_lookup(&branch_head, repo, &branch_id));
+ cl_git_pass(git_annotated_commit_lookup(&onto_head, repo, &onto_id));
+
+ cl_git_pass(git_rebase_init(&rebase, repo, branch_head, NULL, onto_head, NULL));
+ cl_assert_equal_i(GIT_REPOSITORY_STATE_REBASE_MERGE, git_repository_state(repo));
+
+ cl_git_pass(git_rebase_abort(rebase));
+ ensure_aborted(branch_head, onto_head);
+
+ git_annotated_commit_free(branch_head);
+ git_annotated_commit_free(onto_head);
+
+ git_rebase_free(rebase);
+}
+
void test_rebase_abort__detached_head(void)
{
git_rebase *rebase;