show-ref: use die_for_incompatible_opt3()

Use the standard message for reporting the use of multiple mutually
exclusive options by calling die_for_incompatible_opt3() instead of
rolling our own.  This has the benefits of showing only the actually
given options, reducing the number of strings to translate and making
the UI slightly more consistent.

Adjust the test to no longer insist on a specific order of the
reported options, as this implementation detail does not affect the
usefulness of the error message.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2023-12-11 09:09:28 +01:00
committed by Junio C Hamano
parent 564d0252ca
commit 7382497372
2 changed files with 12 additions and 10 deletions

View File

@ -315,9 +315,9 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, show_ref_options,
show_ref_usage, 0);
if ((!!exclude_existing_opts.enabled + !!verify + !!exists) > 1)
die(_("only one of '%s', '%s' or '%s' can be given"),
"--exclude-existing", "--verify", "--exists");
die_for_incompatible_opt3(exclude_existing_opts.enabled, "--exclude-existing",
verify, "--verify",
exists, "--exists");
if (exclude_existing_opts.enabled)
return cmd_show_ref__exclude_existing(&exclude_existing_opts);