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

Re: git-rebase -i prunes commits with empty commit-message

From
Erik Faye-Lund <kusmabite@googlemail.com>
Date
Mar 11, 2010, 13:14 UTC
Message-ID
<40aa078e1003110514n3bdf12ecq6b3a77e0312e742d@mail.gmail.com>
In-Reply-To
<40aa078e1003100534j189eef5kd60855f80e9dd626@mail.gmail.com>

On Wed, Mar 10, 2010 at 2:34 PM, Erik Faye-Lund <kusmabite@googlemail.com> wrote:

Show 7 quoted lines
>
> But to be honest, it seems to me like in this precise instance it's
> probably better to just fix git-rebase--interactive.sh. There's no
> good reason for it to barf on the commits -- especially since
> noon-interactive rebase handles them just fine. Unless someone screams
> out loud, I might take a stab at it when I get time.
>

I think I've found the culprit: git-rev-list doesn't append a newline-separator after commits with empty messages. git-rebase--interactive.sh basically eats git rev-list's output line by line, prepending "pick ".

This seems to have been introduced in 55246aa "Don't use "<unknown>" for placeholders and suppress printing of empty user formats." by Michal Vitecek. It seems he intended to fix a rev-list with --pretty=format:"" or something like that, but I can't get custom formats to work at all with rev-list, even if the documentation says it should.

Anyway, the following patch seems to fix the problem for me, but I'm not very confident that it doesn't break whatever Michal was trying to address.

--->8---
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 5679170..b13e1ba 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -134,10 +134,8 @@ static void show_commit(struct commit *commit, void *data)
                                if (graph_show_remainder(revs->graph))
                                        putchar('\n');
                        }
-               } else {
-                       if (buf.len)
-                               printf("%s%c", buf.buf, info->hdr_termination);
-               }
+               } else
+                       printf("%s%c", buf.buf, info->hdr_termination);
                strbuf_release(&buf);
        } else {
                if (graph_show_remainder(revs->graph))
--->8---
-- 
Erik "kusma" Faye-Lund
Previous: Erik Faye-LundNext: Erik Faye-Lund
Message 4 of 6 in “git-rebase -i prunes commits with empty commit-message”
  1. Erik Faye-LundMar 8, 2010
  2. Michael HaggertyMar 10, 2010
  3. Erik Faye-LundMar 10, 2010
  4. Erik Faye-LundMar 11, 2010
  5. Erik Faye-LundMar 11, 2010
  6. Junio C HamanoMar 10, 2010

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.