From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 0/2] die_for_incompatible_opts(): unbounded number of options
Date: Wed, 26 Aug 2026 16:31:50 -0700 [thread overview]
Message-ID: <20260826233152.1703497-1-gitster@pobox.com> (raw)
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
next reply other threads:[~2026-08-26 23:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 23:31 Junio C Hamano [this message]
2026-08-26 23:31 ` [PATCH 1/2] die_for_incompatible_optN: swap the order of arguments Junio C Hamano
2026-08-26 23:31 ` [PATCH 2/2] die_for_incompatible_opts(): accept more than four options Junio C Hamano
2026-08-27 1:19 ` Elijah Newren
2026-08-27 14:22 ` Junio C Hamano
2026-08-27 4:55 ` Jeff King
2026-08-27 14:35 ` Junio C Hamano
2026-08-27 17:28 ` [PATCH v2] die_for_incompatible_opts(): unbounded number of options Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826233152.1703497-1-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).