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

Re: [PATCH 0/2] parse-options: introduce die_for_required_opt() helper

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 4, 2026, 07:45 UTC
Message-ID
<CAP8UFD2=3V6wRRJU0c1KJ-tGdz_F1DtjNd1aV9dWoO8LK5oeSQ@mail.gmail.com>
In-Reply-To
<20260603111044.39116-1-r.siddharth.shrimali@gmail.com>

On Wed, Jun 3, 2026 at 1:11 PM Siddharth Shrimali <r.siddharth.shrimali@gmail.com> wrote:

Show 9 quoted lines
>
> Many built-in commands in Git manually check for option prerequisites
> (i.e., option X relies on option Y being present) using explicit
> conditional blocks and duplicated error message strings.
>
> This short series comes out of a discussion with Christian about
> localization and code duplication. To address these issues, it
> introduces a centralized API helper that handles simple option
> prerequisites safely.

I think it would be nice to mention around here that the new function was inspired by die_for_incompatible_opt2() and similar functions.

Show 9 quoted lines
> - Patch 1 introduces the `die_for_required_opt()` helper function
>   inside parse-options.
>
> - Patch 2 cleans up `builtin/add.c` as a proof-of-concept by migrating
>   its manual prerequisite checks for '--ignore-missing' and
>   '--pathspec-file-nul' over to the new helper.
>
> If this initial approach looks good, we can later extend the helper
> to handle more complex multi-option dependencies.

Yeah, for functions with more arguments to address cases like "option X requires both options Y and Z" or "option X requires either option Y or option Z", I think it's not clear yet what would be the most useful and what's the best name for such functions.

Previous: Junio C HamanoNext: Siddharth Shrimali
Message 9 of 10 in “parse-options: introduce die_for_required_opt() helper”
  1. 0/2 parse-options: introduce die_for_required_opt() helperSiddharth Shrimali, Jun 3, 2026
  2. 1/2 parse-options: introduce die_for_required_opt()Siddharth Shrimali, Jun 3, 2026
  3. Jean-Noël AVILAJun 3, 2026
  4. Christian CouderJun 4, 2026
  5. Christian CouderJun 4, 2026
  6. 2/2 builtin/add: use die_for_required_opt() helperSiddharth Shrimali, Jun 3, 2026
  7. Christian CouderJun 4, 2026
  8. Junio C HamanoJun 8, 2026
  9. Christian CouderJun 4, 2026
  10. parse-options: introduce die_for_missing_opt()Siddharth Shrimali, Jun 8, 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.