diff options
author | Thomas Rast <trast@student.ethz.ch> | 2009-10-29 01:10:06 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-10-29 02:45:24 +0300 |
commit | 4d23660e79dbbb7e2ae37cb7193166d085a78502 (patch) | |
tree | 36adf863ee02414255a4a5b1570202ff176f721e /builtin-describe.c | |
parent | cd0f8e6d63d3e2744d7d3b2329238be7d064a8ea (diff) |
describe: when failing, tell the user about options that work
Users seem to call git-describe without reading the manpage, and then
wonder why it doesn't work with unannotated tags by default.
Make a minimal effort towards seeing if there would have been
unannotated tags, and tell the user. Specifically, we say that --tags
could work if we found any unannotated tags. If not, we say that
--always would have given results.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-describe.c')
-rw-r--r-- | builtin-describe.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/builtin-describe.c b/builtin-describe.c index eaa8a9d229..504d9b1209 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -96,8 +96,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void if (!all) { if (!prio) return 0; - if (!tags && prio < 2) - return 0; } add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1); return 0; @@ -184,6 +182,7 @@ static void describe(const char *arg, int last_one) struct possible_tag all_matches[MAX_TAGS]; unsigned int match_cnt = 0, annotated_cnt = 0, cur_match; unsigned long seen_commits = 0; + unsigned int unannotated_cnt = 0; if (get_sha1(arg, sha1)) die("Not a valid object name %s", arg); @@ -217,7 +216,9 @@ static void describe(const char *arg, int last_one) seen_commits++; n = c->util; if (n) { - if (match_cnt < max_candidates) { + if (!tags && !all && n->prio < 2) { + unannotated_cnt++; + } else if (match_cnt < max_candidates) { struct possible_tag *t = &all_matches[match_cnt++]; t->name = n; t->depth = seen_commits - 1; @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one) printf("%s\n", find_unique_abbrev(sha1, abbrev)); return; } - die("cannot describe '%s'", sha1_to_hex(sha1)); + if (unannotated_cnt) + die("No annotated tags can describe '%s'.\n" + "However, there were unannotated tags: try --tags.", + sha1_to_hex(sha1)); + else + die("No tags can describe '%s'.\n" + "Try --always, or create some tags.", + sha1_to_hex(sha1)); } qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt); |