From 5acf18ac6304fc216f1adecba64d61c895a883c8 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 2 Jun 2016 01:58:25 -0500 Subject: [PATCH] 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. --- tests/rebase/inmemory.c | 43 ++++++++++++++++++ tests/rebase/merge.c | 39 ++++++++++++++++ .../1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae | Bin 0 -> 31 bytes .../5a/72bf3bf964fdb176ffa4587312e69e2039695a | Bin 0 -> 49 bytes .../77/0f14546ee2563a26c52afa5cc4139a96e5d360 | Bin 0 -> 238 bytes .../91/4f3c604d1098847b7fe275f659ee329878153f | Bin 0 -> 48 bytes .../d9/c5185186d95d233dc007c1927cb3bdd6cde35b | Bin 0 -> 165 bytes .../rebase/.gitted/refs/heads/deep_gravy | Bin 0 -> 41 bytes 8 files changed, 82 insertions(+) create mode 100644 tests/resources/rebase/.gitted/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae create mode 100644 tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a create mode 100644 tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360 create mode 100644 tests/resources/rebase/.gitted/objects/91/4f3c604d1098847b7fe275f659ee329878153f create mode 100644 tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b create mode 100644 tests/resources/rebase/.gitted/refs/heads/deep_gravy diff --git a/tests/rebase/inmemory.c b/tests/rebase/inmemory.c index 7ce865b2f..367d6b3ac 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 74507e258..0f06ed153 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 0000000000000000000000000000000000000000..6230fdf3572a956500c2620856e6128382dc67a0 GIT binary patch literal 31 ncmb+Z{2VYrjL_8fA$Lc?8T5bhvOUo)zb~! literal 0 HcmV?d00001 diff --git a/tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a b/tests/resources/rebase/.gitted/objects/5a/72bf3bf964fdb176ffa4587312e69e2039695a new file mode 100644 index 0000000000000000000000000000000000000000..80eb921d64873e3ef7ead63046661ce9ebea7fe7 GIT binary patch literal 49 zcmV-10M7q-0V^p=O;s>9VlXr?Ff%bxNXyJgWsq(D$YvVn%(-at6Rk^&j_laGuY4T< H{4Eb|&W05t literal 0 HcmV?d00001 diff --git a/tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360 b/tests/resources/rebase/.gitted/objects/77/0f14546ee2563a26c52afa5cc4139a96e5d360 new file mode 100644 index 0000000000000000000000000000000000000000..6091d54a09c8f3da365d2524517602ee4f204418 GIT binary patch literal 238 zcmV5wO}wbFfcPQQAjK9W-u`T0)@QP;*!)9hNzJ*^> literal 0 HcmV?d00001 diff --git a/tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b b/tests/resources/rebase/.gitted/objects/d9/c5185186d95d233dc007c1927cb3bdd6cde35b new file mode 100644 index 0000000000000000000000000000000000000000..3c340db849e62b13d782c6740053ac56142a69cd GIT binary patch literal 165 zcmV;W09yZe0iBLpYQr!P0Q0R=>;+O*k6l?1Lh{iY^a3ksRU2X}I10Uf-7EBO7#Nt+ z*L4}-ygiLw6=K9@0|i!f#9ka1a?*rK3Dze`tW-UtdCIQafXbF@ia0sVF=tl`H#?!k zQX~aT$>%7<&B%MqeTUEbBYTCfxv#Ij!9@@IN4M`~%7}=CH@* T(Es-4UMmQ+<)P*mi)Bej+>lRj literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..efbe5f0a07ff51a436bd873fbd03f44ac8aadbd3 GIT binary patch literal 41 tcmWN