Subject: Re: [PATCH 4/7] revision, rev-parse: factorize incompatibility messages about --exclude-hidden

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 6 Dec 2023 14:08:09 +0100

On Wed, Dec 06, 2023 at 12:51:58PM +0100, René Scharfe wrote:
> Use the standard parameterized message for reporting incompatible
> options to report options that are not accepted in combination with
> --exclude-hidden.  This reduces the number of strings to translate and
> makes the UI a bit more consistent.
> 
> Signed-off-by: René Scharfe <[email-masked]>
> ---
>  builtin/rev-parse.c                |  9 ++++++---
>  revision.c                         | 18 ++++++++++++------
>  t/t6018-rev-list-glob.sh           |  6 ++----
>  t/t6021-rev-list-exclude-hidden.sh |  4 ++--
>  4 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> index fde8861ca4..917f122440 100644
> --- a/builtin/rev-parse.c
> +++ b/builtin/rev-parse.c
> @@ -893,13 +893,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
>  			}
>  			if (opt_with_value(arg, "--branches", &arg)) {
>  				if (ref_excludes.hidden_refs_configured)
> -					return error(_("--exclude-hidden cannot be used together with --branches"));
> +					return error(_("options '%s' and '%s' cannot be used together"),
> +						     "--exclude-hidden", "--branches");

The repetitive nature of this patch and subsequent ones made me wonder
whether it would be useful to have a function similar to the
`die_for_incompatible_*()` helper that knows to format this error
correctly.

Patrick