]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: handle rebase-merges for "onto" message
authorDoan Tran Cong Danh <congdanhqx@gmail.com>
Mon, 18 Nov 2019 11:57:47 +0000 (18:57 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2019 02:53:57 +0000 (11:53 +0900)
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>
sequencer.c
t/t3430-rebase-merges.sh

index fece07b680f2c913047c9d32dcaee9a175fa27d5..9147d02f53d0cb4c40b8ea059fb4b9a80aae3781 100644 (file)
@@ -4560,10 +4560,15 @@ static int make_script_with_merges(struct pretty_print_context *pp,
        strbuf_init(&state.buf, 32);
 
        if (revs->cmdline.nr && (revs->cmdline.rev[0].flags & BOTTOM)) {
+               struct labels_entry *onto_label_entry;
                struct object_id *oid = &revs->cmdline.rev[0].item->oid;
                FLEX_ALLOC_STR(entry, string, "onto");
                oidcpy(&entry->entry.oid, oid);
                oidmap_put(&state.commit2label, entry);
+
+               FLEX_ALLOC_STR(onto_label_entry, label, "onto");
+               hashmap_entry_init(&onto_label_entry->entry, strihash("onto"));
+               hashmap_add(&state.labels, &onto_label_entry->entry);
        }
 
        /*
index f728aba995b2fdc85e9c899372f00e3504d99184..4e2c0ede51d3946125238173913342cb9927b85a 100755 (executable)
@@ -474,4 +474,25 @@ test_expect_success '--rebase-merges with commit that can generate bad character
        git rebase --rebase-merges --force-rebase E
 '
 
+test_expect_success '--rebase-merges with message matched with onto label' '
+       git checkout -b onto-label E &&
+       git merge -m onto G &&
+       git rebase --rebase-merges --force-rebase E &&
+       test_cmp_graph <<-\EOF
+       *   onto
+       |\
+       | * G
+       | * F
+       * |   E
+       |\ \
+       | * | B
+       * | | D
+       | |/
+       |/|
+       * | C
+       |/
+       * A
+       EOF
+'
+
 test_done