]> Kevux Git Server - rit/commit
parse-options: recognize abbreviated negated option with arg
authorRené Scharfe <l.s.r@web.de>
Sun, 3 Mar 2024 12:19:38 +0000 (13:19 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 Mar 2024 17:49:21 +0000 (09:49 -0800)
commit289cb15541874e5c1599fee2e145a7af39085069
tree53f3315d77d35f6f7d108a9ef8a741207cba7b89
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0
parse-options: recognize abbreviated negated option with arg

Giving an argument to an option that doesn't take one causes Git to
report that error specifically:

   $ git rm --dry-run=bogus
   error: option `dry-run' takes no value

The same is true when the option is negated or abbreviated:

   $ git rm --no-dry-run=bogus
   error: option `no-dry-run' takes no value

   $ git rm --dry=bogus
   error: option `dry-run' takes no value

Not so when doing both, though:

   $ git rm --no-dry=bogus
   error: unknown option `no-dry=bogus'
   usage: git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]

(Rest of the usage message omitted.)

Improve consistency and usefulness of the error message by recognizing
abbreviated negated options even if they have a (most likely bogus)
argument.  With this patch we get:

   $ git rm --no-dry=bogus
   error: option `no-dry-run' takes no value

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parse-options.c
t/t0040-parse-options.sh