describe: load refnames before calling describe()
Get rid of the static variable that was used to prevent loading all the refnames multiple times by moving that code out of describe(), simply making sure it is only run once that way. Also change the error message that is shown in case no refnames are found to not include a hash any more, as the error condition is not specific to any particular revision. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Oct 17, 2009 at 18:30 UTC
fb423da0e5668f3945c5a3e34fe5953cde6985a4
1 file changed
+4
-9
builtin-describe.c
+4
-9
@@ -180,7 +180,6 @@ static void describe(const char *arg, int last_one)
180
unsigned char sha1[20];
181
struct commit *cmit, *gave_up_on = NULL;
182
struct commit_list *list;
183
- static int initialized = 0;
183
struct commit_name *n;
184
struct possible_tag all_matches[MAX_TAGS];
185
unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
@@ -192,14 +191,6 @@ static void describe(const char *arg, int last_one)
191
if (!cmit)
192
die("%s is not a valid '%s' object", arg, commit_type);
193
195
- if (!initialized) {
196
- initialized = 1;
197
- for_each_ref(get_name, NULL);
198
- }
199
-
200
- if (!found_names)
201
- die("cannot describe '%s'", sha1_to_hex(sha1));
202
-
194
n = cmit->util;
195
if (n) {
196
/*
@@ -359,6 +350,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
350
return cmd_name_rev(i + argc, args, prefix);
351
}
352
353
+ for_each_ref(get_name, NULL);
354
+ if (!found_names)
355
+ die("No names found, cannot describe anything.");
356
+
357
if (argc == 0) {
358
describe("HEAD", 1);
359
} else {