{"thread":{"id":"21266","subject":"[PATCH] describe: load refnames before calling describe()","startedAt":"2009-10-17T16:30:48Z","lastAt":"2009-10-19T08:05:51Z","messageCount":2,"participants":["René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"125244","messageId":"4AD9F138.3080405@lsrfire.ath.cx","threadId":"21266","inReplyTo":null,"subject":"[PATCH] describe: load refnames before calling describe()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-10-17T16:30:48Z","receivedAt":"2009-10-17T16:30:48Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Get rid of the static variable that was used to prevent loading all\nthe refnames multiple times by moving that code out of describe(),\nsimply making sure it is only run once that way.\n\nAlso change the error message that is shown in case no refnames are\nfound to not include a hash any more, as the error condition is not\nspecific to any particular revision.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n builtin-describe.c |   13 ++++---------\n 1 files changed, 4 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex df67a73..2dcfd3d 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -180,7 +180,6 @@ static void describe(const char *arg, int last_one)\n \tunsigned char sha1[20];\n \tstruct commit *cmit, *gave_up_on = NULL;\n \tstruct commit_list *list;\n-\tstatic int initialized = 0;\n \tstruct commit_name *n;\n \tstruct possible_tag all_matches[MAX_TAGS];\n \tunsigned int match_cnt = 0, annotated_cnt = 0, cur_match;\n@@ -192,14 +191,6 @@ static void describe(const char *arg, int last_one)\n \tif (!cmit)\n \t\tdie(\"%s is not a valid '%s' object\", arg, commit_type);\n \n-\tif (!initialized) {\n-\t\tinitialized = 1;\n-\t\tfor_each_ref(get_name, NULL);\n-\t}\n-\n-\tif (!found_names)\n-\t\tdie(\"cannot describe '%s'\", sha1_to_hex(sha1));\n-\n \tn = cmit->util;\n \tif (n) {\n \t\t/*\n@@ -359,6 +350,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\treturn cmd_name_rev(i + argc, args, prefix);\n \t}\n \n+\tfor_each_ref(get_name, NULL);\n+\tif (!found_names)\n+\t\tdie(\"No names found, cannot describe anything.\");\n+\n \tif (argc == 0) {\n \t\tdescribe(\"HEAD\", 1);\n \t} else {\n-- \n1.6.5\n"},{"id":"125356","messageId":"7vy6n74xls.fsf@alter.siamese.dyndns.org","threadId":"21266","inReplyTo":"4AD9F138.3080405@lsrfire.ath.cx","subject":"Re: [PATCH] describe: load refnames before calling describe()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-19T08:05:51Z","receivedAt":"2009-10-19T08:05:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, applied.\n"}]}