rebase --rebase-merges: root commits can be cousins, too
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 3 May 2018 23:01:29 +0000 (01:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 6 May 2018 04:21:58 +0000 (13:21 +0900)
Reported by Wink Saville: when rebasing with no-rebase-cousins, we
will want to refrain from rebasing all of them, even when they are
root commits.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/t3430-rebase-merges.sh
index 65a8c493781034aa9a5a5651cb4a1db06aa213a8..01e561bc20ec39587c6b4852c3deff9beb20a3f4 100644 (file)
@@ -3903,7 +3903,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
                }
 
                if (!commit)
-                       fprintf(out, "%s onto\n", cmd_reset);
+                       fprintf(out, "%s %s\n", cmd_reset,
+                               rebase_cousins ? "onto" : "[new root]");
                else {
                        const char *to = NULL;
 
index 5543f1d5a346057548c633f6c718a0c6c5f568fe..ce6de6f491e5a6bf5f1d767e14af2b19c467330b 100755 (executable)
@@ -287,5 +287,30 @@ test_expect_success 'a "merge" into a root commit is a fast-forward' '
        test_cmp_rev HEAD $head
 '
 
+test_expect_success 'A root commit can be a cousin, treat it that way' '
+       git checkout --orphan khnum &&
+       test_commit yama &&
+       git checkout -b asherah master &&
+       test_commit shamkat &&
+       git merge --allow-unrelated-histories khnum &&
+       test_tick &&
+       git rebase -f -r HEAD^ &&
+       ! test_cmp_rev HEAD^2 khnum &&
+       test_cmp_graph HEAD^.. <<-\EOF &&
+       *   Merge branch '\''khnum'\'' into asherah
+       |\
+       | * yama
+       o shamkat
+       EOF
+       test_tick &&
+       git rebase --rebase-merges=rebase-cousins HEAD^ &&
+       test_cmp_graph HEAD^.. <<-\EOF
+       *   Merge branch '\''khnum'\'' into asherah
+       |\
+       | * yama
+       |/
+       o shamkat
+       EOF
+'
 
 test_done