* objectname:short bug?
@ 2010-08-26 21:16 Jay Soffian
2010-08-26 21:34 ` [PATCH] for-each-ref: fix objectname:short bug Jay Soffian
0 siblings, 1 reply; 4+ messages in thread
From: Jay Soffian @ 2010-08-26 21:16 UTC (permalink / raw)
To: git; +Cc: Michael J Gruber, Sam Vilain
$ ./git version
git version 1.7.1.88.g67687
$ ./git for-each-ref --format='%(objectname) %(refname:short)'
refs/tags | head -5
d5aef6e4d58cfe1549adef5b436f3ace984e8c86 gitgui-0.10.0
33682a5e98adfd8ba4ce0e21363c443bd273eb77 gitgui-0.10.1
ca9b793bda20c7d011c96895e9407fac2df9648b gitgui-0.10.2
8c178f72b54f387b84388d093a920ae45b8659dd gitgui-0.11.0
15c7170c8c1f6d4f8b8aa539987a92c45d06be9e gitgui-0.12.0
$ ./git for-each-ref --format='%(objectname:short) %(refname:short)'
refs/tags | head -5
8b1e557 gitgui-0.10.0
8b1e557 gitgui-0.10.1
8b1e557 gitgui-0.10.2
8b1e557 gitgui-0.11.0
8b1e557 gitgui-0.12.0
Just checked tip-of-master (b5442ca) and the issue still appears.
j.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] for-each-ref: fix objectname:short bug
2010-08-26 21:16 objectname:short bug? Jay Soffian
@ 2010-08-26 21:34 ` Jay Soffian
2010-08-26 22:15 ` Jeff King
2010-08-27 7:08 ` Michael J Gruber
0 siblings, 2 replies; 4+ messages in thread
From: Jay Soffian @ 2010-08-26 21:34 UTC (permalink / raw)
To: git; +Cc: Jay Soffian, Michael J Gruber, Sam Vilain, Jeff King,
Junio C Hamano
When objectname:short was introduced, it forgot to copy the result of
find_unique_abbrev. Because the result of find_unique_abbrev is a
pointer to static buffer, this resulted in the same value being
substituted in for each ref.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
builtin/for-each-ref.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index a2b28c6..89e75c6 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
v->s = s;
}
else if (!strcmp(name, "objectname:short")) {
- v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
+ v->s = xstrdup(find_unique_abbrev(obj->sha1,
+ DEFAULT_ABBREV));
}
}
}
--
1.7.2.2.170.gb30b3d
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] for-each-ref: fix objectname:short bug
2010-08-26 21:34 ` [PATCH] for-each-ref: fix objectname:short bug Jay Soffian
@ 2010-08-26 22:15 ` Jeff King
2010-08-27 7:08 ` Michael J Gruber
1 sibling, 0 replies; 4+ messages in thread
From: Jeff King @ 2010-08-26 22:15 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, Michael J Gruber, Sam Vilain, Junio C Hamano
On Thu, Aug 26, 2010 at 05:34:29PM -0400, Jay Soffian wrote:
> When objectname:short was introduced, it forgot to copy the result of
> find_unique_abbrev. Because the result of find_unique_abbrev is a
> pointer to static buffer, this resulted in the same value being
> substituted in for each ref.
Yuck. I can't believe neither Michael nor I noticed this on first
review.
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
> v->s = s;
> }
> else if (!strcmp(name, "objectname:short")) {
> - v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
> + v->s = xstrdup(find_unique_abbrev(obj->sha1,
> + DEFAULT_ABBREV));
Your fix looks correct. It obviously leaks, but then so does 99% of the
rest of for-each-ref.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] for-each-ref: fix objectname:short bug
2010-08-26 21:34 ` [PATCH] for-each-ref: fix objectname:short bug Jay Soffian
2010-08-26 22:15 ` Jeff King
@ 2010-08-27 7:08 ` Michael J Gruber
1 sibling, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2010-08-27 7:08 UTC (permalink / raw)
To: Jay Soffian; +Cc: git, Sam Vilain, Jeff King, Junio C Hamano
Jay Soffian venit, vidit, dixit 26.08.2010 23:34:
> When objectname:short was introduced, it forgot to copy the result of
> find_unique_abbrev. Because the result of find_unique_abbrev is a
> pointer to static buffer, this resulted in the same value being
> substituted in for each ref.
>
> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
> ---
> builtin/for-each-ref.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
> index a2b28c6..89e75c6 100644
> --- a/builtin/for-each-ref.c
> +++ b/builtin/for-each-ref.c
> @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
> v->s = s;
> }
> else if (!strcmp(name, "objectname:short")) {
> - v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);
> + v->s = xstrdup(find_unique_abbrev(obj->sha1,
> + DEFAULT_ABBREV));
> }
> }
> }
3 words:
embarrassing - sorry - thanks!
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-27 7:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-26 21:16 objectname:short bug? Jay Soffian
2010-08-26 21:34 ` [PATCH] for-each-ref: fix objectname:short bug Jay Soffian
2010-08-26 22:15 ` Jeff King
2010-08-27 7:08 ` Michael J Gruber
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).