Skip to content

Commit 8fa6eea

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9c85a1c commit 8fa6eea

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3903,7 +3903,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
39033903
}
39043904

39053905
if (!commit)
3906-
fprintf(out, "%s onto\n", cmd_reset);
3906+
fprintf(out, "%s %s\n", cmd_reset,
3907+
rebase_cousins ? "onto" : "[new root]");
39073908
else {
39083909
const char *to = NULL;
39093910

t/t3430-rebase-merges.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,30 @@ test_expect_success 'a "merge" into a root commit is a fast-forward' '
287287
test_cmp_rev HEAD $head
288288
'
289289

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+
'
290315

291316
test_done

0 commit comments

Comments
 (0)