Subject: Re: [PATCH 1/2] parse-options: introduce die_for_required_opt()

From: Jean-Noël AVILA <[email-masked]>
Date: Wed, 03 Jun 2026 21:48:53 +0200

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 <[email-masked]>
> Signed-off-by: Siddharth Shrimali <[email-masked]>
> ---
>  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.