@@ -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) {
@@ -715,4 +715,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