merge: simplify parsing of "-n" option
commit7fa701106d485f7bf9d042f822d4366d7059f8ba
authorJeff King <peff@peff.net>
Thu, 31 Aug 2023 21:17:16 +0000 (31 17:17 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 31 Aug 2023 22:07:10 +0000 (31 15:07 -0700)
tree0008c61b099c0a96f3ebcfd24ac4b95faf67115e
parentdee02da8264bf7e47c8f2689663fac98d31ee450
merge: simplify parsing of "-n" option

The "-n" option is implemented by an option callback, as it is really a
"reverse bool". If given, it sets show_diffstat to 0. In theory, when
negated, it would set the same flag to 1. But it's not possible to
trigger that, since short options cannot be negated.

So in practice this is really just a SET_INT to 0. Let's use that
instead, which shortens the code.

Note that negation here would do the wrong thing (as with any SET_INT
with a value of "0"). We could specify PARSE_OPT_NONEG to future-proof
ourselves against somebody adding a long option name (which would make
it possible to negate). But there's not much point:

  1. Nobody is going to do that, because the negated form already
     exists, and is called "--stat" (which is defined separately so that
     "--no-stat" works).

  2. If they did, the BUG() check added by 3284b93862 (parse-options:
     disallow negating OPTION_SET_INT 0, 2023-08-08) will catch it (and
     that check is smart enough to realize that our short-only option is
     OK).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c