Skip to content

Commit 5acf18a

Browse files
author
Edward Thomson
committed
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.
1 parent 91fbf9d commit 5acf18a

File tree

8 files changed

+83
-0
lines changed

8 files changed

+83
-0
lines changed

tests/rebase/inmemory.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,46 @@ void test_rebase_inmemory__no_common_ancestor(void)
165165
git_reference_free(upstream_ref);
166166
git_rebase_free(rebase);
167167
}
168+
169+
void test_rebase_inmemory__with_directories(void)
170+
{
171+
git_rebase *rebase;
172+
git_reference *branch_ref, *upstream_ref;
173+
git_annotated_commit *branch_head, *upstream_head;
174+
git_rebase_operation *rebase_operation;
175+
git_oid commit_id, tree_id;
176+
git_commit *commit;
177+
git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
178+
179+
opts.inmemory = true;
180+
181+
git_oid_fromstr(&tree_id, "a4d6d9c3d57308fd8e320cf2525bae8f1adafa57");
182+
183+
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/deep_gravy"));
184+
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
185+
186+
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
187+
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
188+
189+
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, &opts));
190+
191+
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
192+
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
193+
NULL, NULL));
194+
195+
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
196+
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
197+
NULL, NULL));
198+
199+
cl_git_fail_with(GIT_ITEROVER, git_rebase_next(&rebase_operation, rebase));
200+
201+
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
202+
cl_assert_equal_oid(&tree_id, git_commit_tree_id(commit));
203+
204+
git_commit_free(commit);
205+
git_annotated_commit_free(branch_head);
206+
git_annotated_commit_free(upstream_head);
207+
git_reference_free(branch_ref);
208+
git_reference_free(upstream_ref);
209+
git_rebase_free(rebase);
210+
}

tests/rebase/merge.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,42 @@ void test_rebase_merge__custom_merge_options(void)
750750
git_rebase_free(rebase);
751751
}
752752

753+
void test_rebase_merge__with_directories(void)
754+
{
755+
git_rebase *rebase;
756+
git_reference *branch_ref, *upstream_ref;
757+
git_annotated_commit *branch_head, *upstream_head;
758+
git_rebase_operation *rebase_operation;
759+
git_oid commit_id, tree_id;
760+
git_commit *commit;
761+
762+
git_oid_fromstr(&tree_id, "a4d6d9c3d57308fd8e320cf2525bae8f1adafa57");
763+
764+
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/deep_gravy"));
765+
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/veal"));
766+
767+
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
768+
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
769+
770+
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, NULL));
771+
772+
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
773+
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
774+
NULL, NULL));
775+
776+
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
777+
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
778+
NULL, NULL));
779+
780+
cl_git_fail_with(GIT_ITEROVER, git_rebase_next(&rebase_operation, rebase));
781+
782+
cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
783+
cl_assert_equal_oid(&tree_id, git_commit_tree_id(commit));
784+
785+
git_commit_free(commit);
786+
git_annotated_commit_free(branch_head);
787+
git_annotated_commit_free(upstream_head);
788+
git_reference_free(branch_ref);
789+
git_reference_free(upstream_ref);
790+
git_rebase_free(rebase);
791+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
d9c5185186d95d233dc007c1927cb3bdd6cde35b

0 commit comments

Comments
 (0)