am: simplify --show-current-patch handling
commite5cf20e0926b1091f0e80de6e43296a2c3223dba
authorRené Scharfe <l.s.r@web.de>
Sat, 28 Oct 2023 11:57:44 +0000 (28 13:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 29 Oct 2023 03:05:59 +0000 (29 12:05 +0900)
tree0c03a295622fa71ac5a8c2d4b2c55004d83104b9
parent0025dde775ea20c64dfedff17da15bbef047a1c9
am: simplify --show-current-patch handling

Let the parse-options code detect and handle the use of options that are
incompatible with --show-current-patch.  This requires exposing the
distinction between the "raw" and "diff" sub-modes.  Do that by
splitting the mode RESUME_SHOW_PATCH into RESUME_SHOW_PATCH_RAW and
RESUME_SHOW_PATCH_DIFF and stop tracking sub-modes in a separate struct.

The result is a simpler callback function and more precise error
messages.  The original reports a spurious argument or a NULL pointer:

   $ git am --show-current-patch --show-current-patch=diff
   error: options '--show-current-patch=diff' and '--show-current-patch=raw' cannot be used together
   $ git am --show-current-patch=diff --show-current-patch
   error: options '--show-current-patch=(null)' and '--show-current-patch=diff' cannot be used together

With this patch we get the more precise:

   $ git am --show-current-patch --show-current-patch=diff
   error: --show-current-patch=diff is incompatible with --show-current-patch
   $ git am --show-current-patch=diff --show-current-patch
   error: --show-current-patch is incompatible with --show-current-patch=diff

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