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

Re: A little mystery - crash caused by empty commit message.

From
Jeff King <peff@peff.net>
Date
Feb 10, 2009, 11:32 UTC
Message-ID
<20090210113234.GE12089@coredump.intra.peff.net>
In-Reply-To
<1a6be5fa0902100315q554dc457j8c8476d3f59a314f@mail.gmail.com>
On Tue, Feb 10, 2009 at 12:15:54PM +0100, Tor Arvid Lund wrote:
Show 19 quoted lines
> Then I tried copying the repository to a linux box and tried gdb
> there. Much better. strchr(line, '\n') is called in pretty.c in the
> get_header function. For one of the commits, the 'line' parameter was
> NULL, so I managed to make it not crash with this little patch:
> 
> diff --git a/pretty.c b/pretty.c
> index 8d4dbc9..1b2d097 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -230,6 +230,8 @@ static char *get_header(const struct commit
> *commit, const char *key)
>        const char *line = commit->buffer;
> 
>        for (;;) {
> +               if (line == NULL)
> +                       return NULL;
>                const char *eol = strchr(line, '\n'), *next;
> 
>                if (line == eol)

Hmm. I can't reproduce the crash here with an empty commit message. I tried:

  mkdir repo && cd repo && git init &&
  touch file && git add . &&
  tree=`git write-tree`
  commit=`git commit-tree $tree </dev/null`
  git update-ref HEAD $commit
  git log
Are you sure it's truly an _empty_ commit message? Can you try
  git cat-file commit f67f77edf06bbcebabf430735c751245a4b70f14
and look at the result with xxd, hd, or similar.
> But the question is then - how did I manage to get my repository in
> this state? The commit in question was made by me - I know I entered a
> message when I committed it. I can even find the commit *with* the
> original commit message in another branch... I am sorry to say that my

It _is_ generally hard to get an empty commit message using "git commit". But it's possible there is a bug in cherry-pick, rebase, or some ohter low-level tool that accidentally erased your message as the commit was moved.

-Peff
Previous: Tor Arvid LundNext: Johannes Sixt
Message 2 of 6 in “A little mystery - crash caused by empty commit message.”
  1. Tor Arvid LundFeb 10, 2009
  2. Jeff KingFeb 10, 2009
  3. Johannes SixtFeb 10, 2009
  4. Tor Arvid LundFeb 10, 2009
  5. Jeff KingFeb 10, 2009
  6. Tor Arvid LundFeb 16, 2009

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.