diff options
| -rw-r--r-- | builtin/describe.c | 5 | ||||
| -rwxr-xr-x | t/t6120-describe.sh | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/builtin/describe.c b/builtin/describe.c index 8ec3be87df..a6ef8af32a 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -367,7 +367,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) seen_commits++; - if (match_cnt == max_candidates) { + if (match_cnt == max_candidates || + match_cnt == hashmap_get_size(&names)) { gave_up_on = c; break; } @@ -667,8 +668,6 @@ int cmd_describe(int argc, NULL); if (!hashmap_get_size(&names) && !always) die(_("No names found, cannot describe anything.")); - if (hashmap_get_size(&names) < max_candidates) - max_candidates = hashmap_get_size(&names); if (argc == 0) { if (broken) { diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index 69689d2f36..8e8bfed05b 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -716,4 +716,14 @@ test_expect_success 'describe --broken --dirty with a file with changed stat' ' ) ' +test_expect_success '--always with no refs falls back to commit hash' ' + git rev-parse HEAD >expect && + git describe --no-abbrev --always --match=no-such-tag >actual && + test_cmp expect actual +' + +test_expect_success '--exact-match does not show --always fallback' ' + test_must_fail git describe --exact-match --always +' + test_done |
