diff options
Diffstat (limited to 'builtin-describe.c')
-rw-r--r-- | builtin-describe.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/builtin-describe.c b/builtin-describe.c index 2946457e9a..df554b30af 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -157,7 +157,7 @@ static void display_name(struct commit_name *n) { if (n->prio == 2 && !n->tag) { n->tag = lookup_tag(n->sha1); - if (!n->tag || !n->tag->tag) + if (!n->tag || parse_tag(n->tag) || !n->tag->tag) die("annotated tag %s not available", n->path); if (strcmp(n->tag->tag, n->path)) warning("tag '%s' is really '%s' here", n->tag->tag, n->path); @@ -167,9 +167,11 @@ static void display_name(struct commit_name *n) printf("%s", n->tag->tag); else printf("%s", n->path); - if (longformat) - printf("-0-g%s", - find_unique_abbrev(n->tag->tagged->sha1, abbrev)); +} + +static void show_suffix(int depth, const unsigned char *sha1) +{ + printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev)); } static void describe(const char *arg, int last_one) @@ -196,7 +198,12 @@ static void describe(const char *arg, int last_one) n = cmit->util; if (n) { + /* + * Exact match to an existing ref. + */ display_name(n); + if (longformat) + show_suffix(0, n->tag->tagged->sha1); printf("\n"); return; } @@ -288,8 +295,7 @@ static void describe(const char *arg, int last_one) display_name(all_matches[0].name); if (abbrev) - printf("-%d-g%s", all_matches[0].depth, - find_unique_abbrev(cmit->object.sha1, abbrev)); + show_suffix(all_matches[0].depth, cmit->object.sha1); printf("\n"); if (!last_one) |