{"thread":{"id":"24873","subject":"objectname:short bug?","startedAt":"2010-08-26T21:16:04Z","lastAt":"2010-08-27T07:08:02Z","messageCount":4,"participants":["Jay Soffian","Jeff King","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149086","messageId":"AANLkTikhcAC6Nf=jWQN40ascodaCte6v6e1JPfv-=To-@mail.gmail.com","threadId":"24873","inReplyTo":null,"subject":"objectname:short bug?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-08-26T21:16:04Z","receivedAt":"2010-08-26T21:16:04Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"$ ./git version\ngit version 1.7.1.88.g67687\n\n$ ./git for-each-ref --format='%(objectname) %(refname:short)'\nrefs/tags | head -5\nd5aef6e4d58cfe1549adef5b436f3ace984e8c86 gitgui-0.10.0\n33682a5e98adfd8ba4ce0e21363c443bd273eb77 gitgui-0.10.1\nca9b793bda20c7d011c96895e9407fac2df9648b gitgui-0.10.2\n8c178f72b54f387b84388d093a920ae45b8659dd gitgui-0.11.0\n15c7170c8c1f6d4f8b8aa539987a92c45d06be9e gitgui-0.12.0\n\n$ ./git for-each-ref --format='%(objectname:short) %(refname:short)'\nrefs/tags | head -5\n8b1e557 gitgui-0.10.0\n8b1e557 gitgui-0.10.1\n8b1e557 gitgui-0.10.2\n8b1e557 gitgui-0.11.0\n8b1e557 gitgui-0.12.0\n\nJust checked tip-of-master (b5442ca) and the issue still appears.\n\nj.\n"},{"id":"149088","messageId":"1282858469-22116-1-git-send-email-jaysoffian@gmail.com","threadId":"24873","inReplyTo":"AANLkTikhcAC6Nf=jWQN40ascodaCte6v6e1JPfv-=To-@mail.gmail.com","subject":"[PATCH] for-each-ref: fix objectname:short bug","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-08-26T21:34:29Z","receivedAt":"2010-08-26T21:34:29Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"When objectname:short was introduced, it forgot to copy the result of\nfind_unique_abbrev. Because the result of find_unique_abbrev is a\npointer to static buffer, this resulted in the same value being\nsubstituted in for each ref.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n builtin/for-each-ref.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex a2b28c6..89e75c6 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\t\tv->s = s;\n \t\t}\n \t\telse if (!strcmp(name, \"objectname:short\")) {\n-\t\t\tv->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);\n+\t\t\tv->s = xstrdup(find_unique_abbrev(obj->sha1,\n+\t\t\t\t\t\t\t  DEFAULT_ABBREV));\n \t\t}\n \t}\n }\n-- \n1.7.2.2.170.gb30b3d\n"},{"id":"149091","messageId":"20100826221536.GA10418@coredump.intra.peff.net","threadId":"24873","inReplyTo":"1282858469-22116-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] for-each-ref: fix objectname:short bug","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-08-26T22:15:36Z","receivedAt":"2010-08-26T22:15:36Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 26, 2010 at 05:34:29PM -0400, Jay Soffian wrote:\n\n> When objectname:short was introduced, it forgot to copy the result of\n> find_unique_abbrev. Because the result of find_unique_abbrev is a\n> pointer to static buffer, this resulted in the same value being\n> substituted in for each ref.\n\nYuck. I can't believe neither Michael nor I noticed this on first\nreview.\n\n> --- a/builtin/for-each-ref.c\n> +++ b/builtin/for-each-ref.c\n> @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n>  \t\t\tv->s = s;\n>  \t\t}\n>  \t\telse if (!strcmp(name, \"objectname:short\")) {\n> -\t\t\tv->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);\n> +\t\t\tv->s = xstrdup(find_unique_abbrev(obj->sha1,\n> +\t\t\t\t\t\t\t  DEFAULT_ABBREV));\n\nYour fix looks correct. It obviously leaks, but then so does 99% of the\nrest of for-each-ref.\n\n-Peff\n"},{"id":"149109","messageId":"4C776452.8020200@drmicha.warpmail.net","threadId":"24873","inReplyTo":"1282858469-22116-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] for-each-ref: fix objectname:short bug","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-08-27T07:08:02Z","receivedAt":"2010-08-27T07:08:02Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jay Soffian venit, vidit, dixit 26.08.2010 23:34:\n> When objectname:short was introduced, it forgot to copy the result of\n> find_unique_abbrev. Because the result of find_unique_abbrev is a\n> pointer to static buffer, this resulted in the same value being\n> substituted in for each ref.\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> ---\n>  builtin/for-each-ref.c |    3 ++-\n>  1 files changed, 2 insertions(+), 1 deletions(-)\n> \n> diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\n> index a2b28c6..89e75c6 100644\n> --- a/builtin/for-each-ref.c\n> +++ b/builtin/for-each-ref.c\n> @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n>  \t\t\tv->s = s;\n>  \t\t}\n>  \t\telse if (!strcmp(name, \"objectname:short\")) {\n> -\t\t\tv->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);\n> +\t\t\tv->s = xstrdup(find_unique_abbrev(obj->sha1,\n> +\t\t\t\t\t\t\t  DEFAULT_ABBREV));\n>  \t\t}\n>  \t}\n>  }\n\n3 words:\n\nembarrassing - sorry - thanks!\n\nMichael\n"}]}