Skip to contentSkip to conversation

Fix git-for-each-refs broken for tags

PATCH In review Petr Baudis 2 participants 3 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix git-for-each-refs broken for tags

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.

---

 builtin-for-each-ref.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
builtin-for-each-ref.c +2 -2
index 173bf38..227aa3c 100644
@@ -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);
 	}
 }
#1 lore raw

Thanks for noticing.

This is not like rev-list where we walk all over the map of ancestry graph, so it might be a simpler and better to keep the buffer than to keep duplicate copies of pieces.

#2 lore raw
Quoted 5 lines · Junio C Hamano

Thanks for noticing.

This is not like rev-list where we walk all over the map of ancestry graph, so it might be a simpler and better to keep the buffer than to keep duplicate copies of pieces.

I would rather not do that in any new code since it's gonna be a problem if you use this outside of the standalone command as part of libgit.

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
The meaning of Stonehenge in Traflamadorian, when viewed from above, is:
"Replacement part being rushed with all possible speed."