{"thread":{"id":"23685","subject":"[PATCH RFC] for-each-ref: Field with abbreviated objectname","startedAt":"2010-05-03T20:25:19Z","lastAt":"2010-05-14T05:12:57Z","messageCount":4,"participants":["Michael J Gruber","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"140846","messageId":"61d114759b023b3937f8417ce44c3361f345c6f1.1272918259.git.git@drmicha.warpmail.net","threadId":"23685","inReplyTo":null,"subject":"[PATCH RFC] for-each-ref: Field with abbreviated objectname","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-05-03T20:25:19Z","receivedAt":"2010-05-03T20:25:19Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Introduce a :short modifier to objectname which outputs the abbreviated\nobject name.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nNotes:\n    I hope this finds the favour of the for-each-ref-man.\n    \n    TODO: test, doc\n\n builtin/for-each-ref.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 62be1bb..3a97953 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -227,6 +227,9 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\t\tstrcpy(s, sha1_to_hex(obj->sha1));\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}\n \t}\n }\n \n-- \n1.7.1.328.g9993c\n"},{"id":"140901","messageId":"20100504110134.GA7947@coredump.intra.peff.net","threadId":"23685","inReplyTo":"61d114759b023b3937f8417ce44c3361f345c6f1.1272918259.git.git@drmicha.warpmail.net","subject":"Re: [PATCH RFC] for-each-ref: Field with abbreviated objectname","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-04T11:01:34Z","receivedAt":"2010-05-04T11:01:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 03, 2010 at 10:25:19PM +0200, Michael J Gruber wrote:\n\n> Introduce a :short modifier to objectname which outputs the abbreviated\n> object name.\n\nI don't see any reason not to do this if you have a use for it.\n\n>     TODO: test, doc\n\nYep.\n\n> +\t\telse if (!strcmp(name, \"objectname:short\")) {\n> +\t\t\tv->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV);\n> +\t\t}\n\nIn theory there could be multiple such \":$foo\" tags, and we would have\nto fix this parser. But given that there aren't other modifiers now, I\nthink we can just push that problem off until it happens (if ever).\n\n-Peff\n"},{"id":"141581","messageId":"dc7a785c8051aa1f742b75c03ddd1fdba57272db.1273753841.git.git@drmicha.warpmail.net","threadId":"23685","inReplyTo":"20100504110134.GA7947@coredump.intra.peff.net","subject":"[PATCH] for-each-ref: Field with abbreviated objectname","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-05-13T12:31:46Z","receivedAt":"2010-05-13T12:31:46Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Introduce a :short modifier to objectname which outputs the abbreviated\nobject name.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-for-each-ref.txt |    1 +\n builtin/for-each-ref.c             |    3 +++\n t/t6300-for-each-ref.sh            |    9 +++++++++\n 3 files changed, 13 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex 7e83288..390d85c 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -86,6 +86,7 @@ objectsize::\n \n objectname::\n \tThe object name (aka SHA-1).\n+\tFor a non-ambiguous abbreviation of the object name append `:short`.\n \n upstream::\n \tThe name of a local ref which can be considered ``upstream''\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex 62be1bb..3a97953 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -227,6 +227,9 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\t\tstrcpy(s, sha1_to_hex(obj->sha1));\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}\n \t}\n }\n \ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 8052c86..7dc8a51 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -295,6 +295,15 @@ test_expect_success 'Check short upstream format' '\n \ttest_cmp expected actual\n '\n \n+cat >expected <<EOF\n+67a36f1\n+EOF\n+\n+test_expect_success 'Check short objectname format' '\n+\tgit for-each-ref --format=\"%(objectname:short)\" refs/heads >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success 'Check for invalid refname format' '\n \ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n-- \n1.7.1.240.geeaa4d\n"},{"id":"141635","messageId":"20100514051257.GG6075@coredump.intra.peff.net","threadId":"23685","inReplyTo":"dc7a785c8051aa1f742b75c03ddd1fdba57272db.1273753841.git.git@drmicha.warpmail.net","subject":"Re: [PATCH] for-each-ref: Field with abbreviated objectname","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-05-14T05:12:57Z","receivedAt":"2010-05-14T05:12:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 13, 2010 at 02:31:46PM +0200, Michael J Gruber wrote:\n\n> Introduce a :short modifier to objectname which outputs the abbreviated\n> object name.\n\nLooks fine to me.\n\n-Peff\n"}]}