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

[PATCH] Fix git-for-each-refs broken for tags

From
Petr Baudis <pasky@suse.cz>
Date
Nov 18, 2006, 02:56 UTC
Message-ID
<20061118025652.2970.10571.stgit@machine.or.cz>

Unfortunately, git-for-each-refs is currently unusable for peeking into tag comments, since it uses freed pointers, so it just prints out all sort of garbage.

This makes it strdup() contents and body values.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 builtin-for-each-ref.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index 173bf38..227aa3c 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -478,9 +478,9 @@ static void grab_sub_body_contents(struc
 		if (!strcmp(name, "subject"))
 			v->s = copy_line(subpos);
 		else if (!strcmp(name, "body"))
-			v->s = bodypos;
+			v->s = xstrdup(bodypos);
 		else if (!strcmp(name, "contents"))
-			v->s = subpos;
+			v->s = xstrdup(subpos);
 	}
 }
Next: Junio C Hamano
Message 1 of 3 in “Fix git-for-each-refs broken for tags”
  1. Fix git-for-each-refs broken for tagsPetr Baudis, Nov 18, 2006
  2. Junio C HamanoNov 18, 2006
  3. Petr BaudisNov 18, 2006

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.