[PATCH] fixup! describe: stop traversing when we run out of names
Don't exit when we run out of names if we also set --always
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
builtin/describe.c | 2 +-
t/t6120-describe.sh | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 8ec3be87df..065c1bde6e 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -336,7 +336,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
return;
}
- if (!max_candidates)
+ if (!max_candidates && !always)
die(_("no tag exactly matches '%s'"), oid_to_hex(&cmit->object.oid));
if (debug)
fprintf(stderr, _("No exact match on refs or tags, searching to describe\n"));
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 5633b11d01..9aebf09d3d 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -715,4 +715,18 @@ 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 init always-no-refs &&
+ (
+ cd always-no-refs &&
+ test_commit --no-tag A &&
+ test_commit --no-tag B &&
+ test_commit --no-tag C &&
+ git describe --abbrev=12 --always HEAD^ >actual &&
+ echo 13 >expected_size &&
+ test_file_size actual >actual_size &&
+ test_cmp expected_size actual_size
+ )
+'
+
test_done
base-commit: a4f8a869558d59677e8d9798666a23391f0b4ca8
--
2.47.0.338.g60cca15819-goog