From: Junio C Hamano Date: Wed, 26 Aug 2026 23:31:50 GMT Subject: [PATCH 0/2] die_for_incompatible_opts(): unbounded number of options Message-ID: <20260826233152.1703497-1-gitster@pobox.com> We have die_for_incompatible_optN() (for 2 <= N <= 4) to check and complain when two or more among N mutually incompatible options are used. What should a developer do if there are more than four options that cannot be used at once? Introduce die_for_incompatible_opts(), which can handle an arbitrary number of mutually exclusive options. This is done in two steps: - The API for existing functions takes N pairs (for 2 <= N <= 4) of 'int set, const char *name' parameters that signal which options are set. This parameter order is inconvenient for varargs, where a sentinel value marks the end of the argument list (and there is no clear sentinel value of type 'int'). The first patch rewrites all implementations and callers of die_for_incompatible_optN() to swap the parameter order to pairs of 'const char *name, int set'. - The second patch then introduces die_for_incompatible_opts(), which takes an arbitrary number of 'const char *name, int set' pairs terminated by a NULL sentinel. We could do without the first step and use the 'const char *, int' order only in die_for_incompatible_opts(), leaving the traditional die_for_incompatible_opt[234]() functions using the 'int, const char *' order, but using a consistent ordering is likely easier in the long run. 1/2: die_for_incompatible_optN: swap the order of arguments 2/2: die_for_incompatible_opts(): accept more than four options builtin/add.c | 6 +++--- builtin/clone.c | 8 ++++---- builtin/commit.c | 24 ++++++++++++------------ builtin/difftool.c | 6 +++--- builtin/gc.c | 8 ++++---- builtin/grep.c | 6 +++--- builtin/log.c | 6 +++--- builtin/merge-tree.c | 8 ++++---- builtin/pack-objects.c | 21 ++++++++++----------- builtin/push.c | 8 ++++---- builtin/repack.c | 12 +++++++----- builtin/replay.c | 18 +++++++++--------- builtin/rev-list.c | 6 +++--- builtin/show-ref.c | 7 ++++--- parse-options.c | 26 ++++++++++++++------------ parse-options.h | 40 +++++++++++++++++++++++----------------- revision.c | 26 +++++++++++++------------- 17 files changed, 123 insertions(+), 113 deletions(-) -- 2.55.0-862-g3c6f97f7b9