Commit 5acf18ac6304fc216f1adecba64d61c895a883c8

Edward Thomson 2016-06-02T01:58:25

rebase: test rebasing a new commit with subfolder Test a rebase (both a merge rebase and an inmemory rebase) with a new commit that adds files underneath a new subfolder.

diff --git a/tests/rebase/inmemory.c b/tests/rebase/inmemory.c
index 7ce865b..367d6b3 100644
--- a/tests/rebase/inmemory.c
+++ b/tests/rebase/inmemory.c
@@ -165,3 +165,46 @@ void test_rebase_inmemory__no_common_ancestor(void)
 	git_reference_free(upstream_ref);
 	git_rebase_free(rebase);
 }
+
+void test_rebase_inmemory__with_directories(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_oid commit_id, tree_id;
+	git_commit *commit;
+	git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
+
+	opts.inmemory = true;
+
+	git_oid_fromstr(&tree_id, "a4d6d9c3d57308fd8e320cf2525bae8f1adafa57");
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/deep_gravy"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
+
+	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, &opts));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_fail_with(GIT_ITEROVER, git_rebase_next(&rebase_operation, rebase));
+
+	cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
+	cl_assert_equal_oid(&tree_id, git_commit_tree_id(commit));
+
+	git_commit_free(commit);
+	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);
+}
diff --git a/tests/rebase/merge.c b/tests/rebase/merge.c
index 74507e2..0f06ed1 100644
--- a/tests/rebase/merge.c
+++ b/tests/rebase/merge.c
@@ -750,3 +750,42 @@ void test_rebase_merge__custom_merge_options(void)
 	git_rebase_free(rebase);
 }
 
+void test_rebase_merge__with_directories(void)
+{
+	git_rebase *rebase;
+	git_reference *branch_ref, *upstream_ref;
+	git_annotated_commit *branch_head, *upstream_head;
+	git_rebase_operation *rebase_operation;
+	git_oid commit_id, tree_id;
+	git_commit *commit;
+
+	git_oid_fromstr(&tree_id, "a4d6d9c3d57308fd8e320cf2525bae8f1adafa57");
+
+	cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/deep_gravy"));
+	cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
+
+	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_next(&rebase_operation, rebase));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_pass(git_rebase_next(&rebase_operation, rebase));
+	cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
+		NULL, NULL));
+
+	cl_git_fail_with(GIT_ITEROVER, git_rebase_next(&rebase_operation, rebase));
+
+	cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
+	cl_assert_equal_oid(&tree_id, git_commit_tree_id(commit));
+
+	git_commit_free(commit);
+	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);
+}
diff --git a/tests/resources/rebase/.gitted/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae b/tests/resources/rebase/.gitted/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae
new file mode 100644
index 0000000..6230fdf
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae differ
diff --git a/tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a b/tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a
new file mode 100644
index 0000000..80eb921
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a differ
diff --git a/tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360 b/tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360
new file mode 100644
index 0000000..6091d54
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360 differ
diff --git a/tests/resources/rebase/.gitted/objects/91/4f3c604d1098847b7fe275f659ee329878153f b/tests/resources/rebase/.gitted/objects/91/4f3c604d1098847b7fe275f659ee329878153f
new file mode 100644
index 0000000..726bf91
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/91/4f3c604d1098847b7fe275f659ee329878153f differ
diff --git a/tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b b/tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b
new file mode 100644
index 0000000..3c340db
Binary files /dev/null and b/tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b differ
diff --git a/tests/resources/rebase/.gitted/refs/heads/deep_gravy b/tests/resources/rebase/.gitted/refs/heads/deep_gravy
new file mode 100644
index 0000000..efbe5f0
--- /dev/null
+++ b/tests/resources/rebase/.gitted/refs/heads/deep_gravy
@@ -0,0 +1 @@
+d9c5185186d95d233dc007c1927cb3bdd6cde35b