git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix git-for-each-refs broken for tags
@ 2006-11-18  2:56 Petr Baudis
  2006-11-18  4:45 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Baudis @ 2006-11-18  2:56 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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);
 	}
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix git-for-each-refs broken for tags
  2006-11-18  2:56 [PATCH] Fix git-for-each-refs broken for tags Petr Baudis
@ 2006-11-18  4:45 ` Junio C Hamano
  2006-11-18  4:54   ` Petr Baudis
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-11-18  4:45 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix git-for-each-refs broken for tags
  2006-11-18  4:45 ` Junio C Hamano
@ 2006-11-18  4:54   ` Petr Baudis
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Baudis @ 2006-11-18  4:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, Nov 18, 2006 at 05:45:11AM CET, Junio C Hamano wrote:
> 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.

-- 
				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."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-18  4:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-18  2:56 [PATCH] Fix git-for-each-refs broken for tags Petr Baudis
2006-11-18  4:45 ` Junio C Hamano
2006-11-18  4:54   ` Petr Baudis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).