]> git.ipfire.org Git - thirdparty/git.git/commit
parse-options: normalize arg and long_name before comparison
authorRené Scharfe <l.s.r@web.de>
Sun, 3 Mar 2024 12:19:42 +0000 (13:19 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 Mar 2024 17:49:22 +0000 (09:49 -0800)
commitb1ce2b62fa4c6cf6d972698ac48be451cbc07718
treee7e78be8a4f838fa041a843ec780ff1e8bc0c42f
parent0d8a3097c74ed3b78442c4d533f3427316596a46
parse-options: normalize arg and long_name before comparison

Strip "no-" from arg and long_name before comparing them.  This way we
no longer have to repeat the comparison with an offset of 3 for negated
arguments.

Note that we must not modify the "flags" value, which tracks whether arg
is negated, inside the loop.  When registering "--n", "--no" or "--no-"
as abbreviation for any negative option, we used to OR it with OPT_UNSET
and end the loop.  We can simply hard-code OPT_UNSET and leave flags
unchanged instead.

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