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.