git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] describe: load refnames before calling describe()
@ 2009-10-17 16:30 René Scharfe
  2009-10-19  8:05 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2009-10-17 16:30 UTC (permalink / raw
  To: Git Mailing List; +Cc: Junio C Hamano, Shawn O. Pearce

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>
---
 builtin-describe.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/builtin-describe.c b/builtin-describe.c
index df67a73..2dcfd3d 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 {
-- 
1.6.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] describe: load refnames before calling describe()
  2009-10-17 16:30 [PATCH] describe: load refnames before calling describe() René Scharfe
@ 2009-10-19  8:05 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2009-10-19  8:05 UTC (permalink / raw
  To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano, Shawn O. Pearce

Thanks, applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-19  8:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-17 16:30 [PATCH] describe: load refnames before calling describe() René Scharfe
2009-10-19  8:05 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).