describe: fix --no-exact-match
commitc95ae3ff9cdcbe6229dc3aa4cd7aa14b1354759a
authorRené Scharfe <l.s.r@web.de>
Fri, 21 Jul 2023 13:41:33 +0000 (21 15:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Jul 2023 16:57:15 +0000 (21 09:57 -0700)
treebfab31ec6f9e505a4cfb5e3db94a0707b1fe8985
parentfb7d80edcae482f4fa5d4be0227dc3054734e5f3
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>
builtin/describe.c
t/t6120-describe.sh