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

Re: git for-each-ref crashes for %(body) with tags

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2008, 19:12 UTC
Message-ID
<7vhc9fqz4a.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<f329bf540808201128r2d21c40cr37eb63a6706ac0aa@mail.gmail.com>
"Han-Wen Nienhuys" <hanwenn@gmail.com> writes:
> see gdb trace below.   Unfortunately, I don't have a repo that I can
> readily share to demonstrate this.

You have a tag that has a single incomplete line as its payload. The attached patch should fix it, but I wonder how you created such an unusual (I would not say "broken") tag to begin with?

diff --git i/builtin-for-each-ref.c w/builtin-for-each-ref.c
index 445039e..4d25ec5 100644
--- i/builtin-for-each-ref.c
+++ w/builtin-for-each-ref.c
@@ -459,8 +459,10 @@ static void find_subpos(const char *buf, unsigned long sz, const char **sub, con
 		return;
 	*sub = buf; /* first non-empty line */
 	buf = strchr(buf, '\n');
-	if (!buf)
+	if (!buf) {
+		*body = "";
 		return; /* no body */
+	}
 	while (*buf == '\n')
 		buf++; /* skip blank between subject and body */
 	*body = buf;
Previous: Han-Wen NienhuysNext: Han-Wen Nienhuys
Message 2 of 3 in “git for-each-ref crashes for %(body) with tags”
  1. Han-Wen NienhuysAug 20, 2008
  2. Junio C HamanoAug 20, 2008
  3. Han-Wen NienhuysAug 20, 2008

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.