diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2009-10-17 18:30:48 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-10-18 23:00:02 -0700 |
commit | fb423da0e5668f3945c5a3e34fe5953cde6985a4 (patch) | |
tree | a09587447e9652337f382ecda6ff87685d08caa6 /builtin-describe.c | |
parent | bcc9b7427d9f720127479bb603159de89c93f872 (diff) | |
download | git-fb423da0e5668f3945c5a3e34fe5953cde6985a4.tar.gz |
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>
Diffstat (limited to 'builtin-describe.c')
-rw-r--r-- | builtin-describe.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/builtin-describe.c b/builtin-describe.c index df67a733ae..2dcfd3dfeb 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -180,7 +180,6 @@ static void describe(const char *arg, int last_one) unsigned char sha1[20]; struct commit *cmit, *gave_up_on = NULL; struct commit_list *list; - static int initialized = 0; struct commit_name *n; struct possible_tag all_matches[MAX_TAGS]; unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; @@ -192,14 +191,6 @@ static void describe(const char *arg, int last_one) if (!cmit) die("%s is not a valid '%s' object", arg, commit_type); - if (!initialized) { - initialized = 1; - for_each_ref(get_name, NULL); - } - - if (!found_names) - die("cannot describe '%s'", sha1_to_hex(sha1)); - n = cmit->util; if (n) { /* @@ -359,6 +350,10 @@ int cmd_describe(int argc, const char **argv, const char *prefix) return cmd_name_rev(i + argc, args, prefix); } + for_each_ref(get_name, NULL); + if (!found_names) + die("No names found, cannot describe anything."); + if (argc == 0) { describe("HEAD", 1); } else { |