From: "Jean-Noël AVILA" <jn.avila@free.fr>
To: git@vger.kernel.org, Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Cc: gitster@pobox.com, christian.couder@gmail.com, toon@iotcl.com,
r.siddharth.shrimali@gmail.com
Subject: Re: [PATCH 1/2] parse-options: introduce die_for_required_opt()
Date: Wed, 03 Jun 2026 21:48:53 +0200 [thread overview]
Message-ID: <2412618.ElGaqSPkdT@piment-oiseau> (raw)
In-Reply-To: <20260603111044.39116-2-r.siddharth.shrimali@gmail.com>
On Wednesday, 3 June 2026 13:10:43 CEST Siddharth Shrimali wrote:
> Introduce a new helper function die_for_required_opt() to check if a
> given option is present without its required prerequisite option.
>
> This provides a centralized API for handling simple option dependencies
> (i.e., X requires Y), matching the style of the existing mutual-exclusion
> helpers like die_for_incompatible_opt{2,3,4}().
>
> Suggested-by: Christian Couder <christian.couder@gmail.com>
> Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
> ---
> parse-options.c | 7 +++++++
> parse-options.h | 3 +++
> 2 files changed, 10 insertions(+)
>
> diff --git a/parse-options.c b/parse-options.c
> index a676da86f5..e100f9a0c1 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -1558,3 +1558,10 @@ void die_for_incompatible_opt4(int opt1, const char
> *opt1_name, break;
> }
> }
> +
> +void die_for_required_opt(int opt1, const char *opt1_name,
> + int opt2, const char *opt2_name)
Hello,
First thanks for trying to uniformize/simplify option checking. The
translators will be happy.
To me, "die_for_required_opt" is a misnomer as the function does not die for
an existing "required" condition, unlike the other functions such as
die_for_incompatible_opt<n>.
The names of the parameters do not indicate that the test is not symmetrical
(not failing on XOR).
Maybe something like "die_for_missing_opt(int tested_opt, const char
*tested_opt_name, int required_opt, const char *required_opt_name)
would make it more understandable.
next prev parent reply other threads:[~2026-06-03 19:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 11:10 [PATCH 0/2] parse-options: introduce die_for_required_opt() helper Siddharth Shrimali
2026-06-03 11:10 ` [PATCH 1/2] parse-options: introduce die_for_required_opt() Siddharth Shrimali
2026-06-03 19:48 ` Jean-Noël AVILA [this message]
2026-06-03 11:10 ` [PATCH 2/2] builtin/add: use die_for_required_opt() helper Siddharth Shrimali
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=2412618.ElGaqSPkdT@piment-oiseau \
--to=jn.avila@free.fr \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=r.siddharth.shrimali@gmail.com \
--cc=toon@iotcl.com \
/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