describe: fix --no-exact-match
Since 2c33f75754
(Teach git-describe --exact-match to avoid expensive
tag searches, 2008-02-24) git describe accepts --no-exact-match, but it
does the same as --exact-match, an alias for --candidates=0. That's
because it's defined using OPT_SET_INT with a value of 0, which sets 0
when negated as well.
Let --no-exact-match set the number of candidates to the default value
instead. Users that need a more specific lack of exactitude can specify
their preferred value using --candidates, as before.
The "--no-exact-match" option was not covered in the tests, so let's
add a few. Also add a case where --exact-match option is used on a
commit that cannot be described without distance from tags and make
sure the command fails.
Signed-off-by: René Scharfe <l.s.r@web.de>
[jc: added trivial tests]
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fb7d80edca
commit
c95ae3ff9c
@ -85,6 +85,7 @@ check_describe e-1-gHASH --tags HEAD^^
|
||||
check_describe c-2-gHASH --tags HEAD^^2
|
||||
check_describe B --tags HEAD^^2^
|
||||
check_describe e --tags HEAD^^^
|
||||
check_describe e --tags --exact-match HEAD^^^
|
||||
|
||||
check_describe heads/main --all HEAD
|
||||
check_describe tags/c-6-gHASH --all HEAD^
|
||||
@ -96,6 +97,13 @@ check_describe A-3-gHASH --long HEAD^^2
|
||||
check_describe c-7-gHASH --tags
|
||||
check_describe e-3-gHASH --first-parent --tags
|
||||
|
||||
check_describe c-7-gHASH --tags --no-exact-match HEAD
|
||||
check_describe e-3-gHASH --first-parent --tags --no-exact-match HEAD
|
||||
|
||||
test_expect_success '--exact-match failure' '
|
||||
test_must_fail git describe --exact-match HEAD 2>err
|
||||
'
|
||||
|
||||
test_expect_success 'describe --contains defaults to HEAD without commit-ish' '
|
||||
echo "A^0" >expect &&
|
||||
git checkout A &&
|
||||
|
Reference in New Issue
Block a user