git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] die_for_incompatible_opts(): unbounded number of options

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2026, 23:31 UTC
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
Next: Junio C Hamano
Message 1 of 13 in “die_for_incompatible_opts(): unbounded number of options”
  1. 0/2 die_for_incompatible_opts(): unbounded number of optionsJunio C Hamano, Aug 26, 2026
  2. 1/2 die_for_incompatible_optN: swap the order of argumentsJunio C Hamano, Aug 26, 2026
  3. 2/2 die_for_incompatible_opts(): accept more than four optionsJunio C Hamano, Aug 26, 2026
  4. Elijah NewrenAug 27, 2026
  5. Junio C HamanoAug 27, 2026
  6. Jeff KingAug 27, 2026
  7. Junio C HamanoAug 27, 2026
  8. Jeff KingAug 29, 2026
  9. Junio C HamanoAug 29, 2026
  10. René ScharfeAug 29, 2026
  11. die_for_incompatible_opts(): unbounded number of optionsJunio C Hamano, Aug 27, 2026
  12. Jeff KingAug 29, 2026
  13. Junio C HamanoAug 30, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.