git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug in rebase --autosquash

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Aug 17, 2022, 19:40 UTC
Message-ID
<CAMP44s3iRbqgA9U4SeyRQUXdfqk=Stsw3kGqoGrFDRDWkV6GKA@mail.gmail.com>
In-Reply-To
<20220817094909.v2ev4rpsmxjnii4x@pengutronix.de>

On Wed, Aug 17, 2022 at 4:54 AM Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> after:
...
Show 17 quoted lines
> running
>
>         git rebase -i --autosquash @~2
>
> my editor presents me with:
>
>         pick ef8f0bd27a56 fixup! file with content
>         pick b40a214bf5fb fixup! fixup! file with content
>
> However I would have expected
>
>         pick ef8f0bd27a56 fixup! file with content
>         fixup b40a214bf5fb fixup! fixup! file with content
>
> instead.
>
> Is this a feature I don't understand?

The problem is the code removes all "fixup! " prefixes and then tries to find a commit with that title, which isn't in the list. If you specify the commit hash, then it finds it and it works as you intended.

I don't see why the code would do that though, since you are clearly intending to fix "fixup! file with content", not "file with content".

This patch below (apologies for gmail auto wrapping in advance) should make it work as you intend.

--- a/sequencer.c
+++ b/sequencer.c
@@ -6213,12 +6213,8 @@ int todo_list_rearrange_squash(struct todo_list
*todo_list)
                if (skip_fixupish(subject, &p)) {
                        struct commit *commit2;

-                       for (;;) {
-                               while (isspace(*p))
-                                       p++;
-                               if (!skip_fixupish(p, &p))
-                                       break;
-                       }
+                       while (isspace(*p))
+                               p++;

                        entry = hashmap_get_entry_from_hash(&subject2item,
                                                strhash(p), p,
-- 
Felipe Contreras
Previous: Uwe Kleine-KönigNext: Johannes Schindelin
Message 2 of 4 in “Bug in rebase --autosquash”
  1. Uwe Kleine-KönigAug 17, 2022
  2. Felipe ContrerasAug 17, 2022
  3. Johannes SchindelinAug 19, 2022
  4. Junio C HamanoAug 19, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.