rebase --rebase-merges: root commits can be cousins, too

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>

Johannes Schindelin committed May 4, 2018 at 01:01 UTC 8fa6eea0ffd271f0564048dc939987e9640efca5
2 files changed +27 -1
sequencer.c
+2 -1
@@ -3903,7 +3903,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
3903 }
3904
3905 if (!commit)
3906 - fprintf(out, "%s onto\n", cmd_reset);
3906 + fprintf(out, "%s %s\n", cmd_reset,
3907 + rebase_cousins ? "onto" : "[new root]");
3908 else {
3909 const char *to = NULL;
3910
t/t3430-rebase-merges.sh
+25
@@ -287,5 +287,30 @@ test_expect_success 'a "merge" into a root commit is a fast-forward' '
287 test_cmp_rev HEAD $head
288 '
289
290 +test_expect_success 'A root commit can be a cousin, treat it that way' '
291 + git checkout --orphan khnum &&
292 + test_commit yama &&
293 + git checkout -b asherah master &&
294 + test_commit shamkat &&
295 + git merge --allow-unrelated-histories khnum &&
296 + test_tick &&
297 + git rebase -f -r HEAD^ &&
298 + ! test_cmp_rev HEAD^2 khnum &&
299 + test_cmp_graph HEAD^.. <<-\EOF &&
300 + * Merge branch '\''khnum'\'' into asherah
301 + |\
302 + | * yama
303 + o shamkat
304 + EOF
305 + test_tick &&
306 + git rebase --rebase-merges=rebase-cousins HEAD^ &&
307 + test_cmp_graph HEAD^.. <<-\EOF
308 + * Merge branch '\''khnum'\'' into asherah
309 + |\
310 + | * yama
311 + |/
312 + o shamkat
313 + EOF
314 +'
315
316 test_done