summaryrefslogtreecommitdiff
path: root/tests/rebase/iterator.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-02-11 10:48:48 -0800
committerEdward Thomson <ethomson@github.com>2016-02-11 10:48:48 -0800
commitee6673070a6134f0a1743c866583b14a305b6a43 (patch)
tree44e7b14e9ed28baa15c763332ec8909052970e47 /tests/rebase/iterator.c
parent488e2b85053a45dd2ce6a37b7d5cf70870be5ed8 (diff)
downloadlibgit2-ee6673070a6134f0a1743c866583b14a305b6a43.tar.gz
rebase: introduce inmemory rebasing
Introduce the ability to rebase in-memory or in a bare repository. When `rebase_options.inmemory` is specified, the resultant `git_rebase` session will not be persisted to disk. Callers may still analyze the rebase operations, resolve any conflicts against the in-memory index and create the commits. Neither `HEAD` nor the working directory will be updated during this process.
Diffstat (limited to 'tests/rebase/iterator.c')
-rw-r--r--tests/rebase/iterator.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/tests/rebase/iterator.c b/tests/rebase/iterator.c
index acf2a92db..e761d39d3 100644
--- a/tests/rebase/iterator.c
+++ b/tests/rebase/iterator.c
@@ -46,26 +46,32 @@ static void test_operations(git_rebase *rebase, size_t expected_current)
}
}
-void test_rebase_iterator__iterates(void)
+void test_iterator(bool inmemory)
{
git_rebase *rebase;
+ git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
git_reference *branch_ref, *upstream_ref;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_oid commit_id;
int error;
+ opts.inmemory = inmemory;
+
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));
- cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
+ cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, &opts));
test_operations(rebase, GIT_REBASE_NO_OPERATION);
- git_rebase_free(rebase);
- cl_git_pass(git_rebase_open(&rebase, repo, NULL));
+ if (!inmemory) {
+ git_rebase_free(rebase);
+ cl_git_pass(git_rebase_open(&rebase, repo, NULL));
+ }
+
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
@@ -81,8 +87,10 @@ void test_rebase_iterator__iterates(void)
NULL, NULL));
test_operations(rebase, 2);
- git_rebase_free(rebase);
- cl_git_pass(git_rebase_open(&rebase, repo, NULL));
+ if (!inmemory) {
+ git_rebase_free(rebase);
+ cl_git_pass(git_rebase_open(&rebase, repo, NULL));
+ }
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
@@ -104,3 +112,13 @@ void test_rebase_iterator__iterates(void)
git_reference_free(upstream_ref);
git_rebase_free(rebase);
}
+
+void test_rebase_iterator__iterates(void)
+{
+ test_iterator(false);
+}
+
+void test_rebase_iterator__iterates_inmemory(void)
+{
+ test_iterator(true);
+}