sequencer: handle rebase-merges for "onto" message
In order to work correctly, git-rebase --rebase-merges needs to make initial todo list with unique labels. Those unique labels is being handled by employing a hashmap and appending an unique number if any duplicate is found. But, we forget that beside those labels for side branches, we also have a special label `onto' for our so-called new-base. In a special case that any of those labels for side branches named `onto', git will run into trouble. Correct it. Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Doan Tran Cong Danh committed
Nov 18, 2019 at 18:57 UTC
e02058a72967b18bd906674de6191f42d03b0763
2 files changed
+26
sequencer.c
+5
@@ -4560,10 +4560,15 @@ static int make_script_with_merges(struct pretty_print_context *pp,
4560
strbuf_init(&state.buf, 32);
4561
4562
if (revs->cmdline.nr && (revs->cmdline.rev[0].flags & BOTTOM)) {
4563
+ struct labels_entry *onto_label_entry;
4564
struct object_id *oid = &revs->cmdline.rev[0].item->oid;
4565
FLEX_ALLOC_STR(entry, string, "onto");
4566
oidcpy(&entry->entry.oid, oid);
4567
oidmap_put(&state.commit2label, entry);
4568
+
4569
+ FLEX_ALLOC_STR(onto_label_entry, label, "onto");
4570
+ hashmap_entry_init(&onto_label_entry->entry, strihash("onto"));
4571
+ hashmap_add(&state.labels, &onto_label_entry->entry);
4572
}
4573
4574
/*
t/t3430-rebase-merges.sh
+21
@@ -474,4 +474,25 @@ test_expect_success '--rebase-merges with commit that can generate bad character
474
git rebase --rebase-merges --force-rebase E
475
'
476
477
+test_expect_success '--rebase-merges with message matched with onto label' '
478
+ git checkout -b onto-label E &&
479
+ git merge -m onto G &&
480
+ git rebase --rebase-merges --force-rebase E &&
481
+ test_cmp_graph <<-\EOF
482
+ * onto
483
+ |\
484
+ | * G
485
+ | * F
486
+ * | E
487
+ |\ \
488
+ | * | B
489
+ * | | D
490
+ | |/
491
+ |/|
492
+ * | C
493
+ |/
494
+ * A
495
+ EOF
496
+'
497
+
498
test_done