* [PATCH] i18n: factorize even more 'incompatible options' messages
@ 2023-11-26 11:57 René Scharfe
2023-11-26 17:49 ` Eric Sunshine
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: René Scharfe @ 2023-11-26 11:57 UTC (permalink / raw)
To: Git List; +Cc: Jean-Noël Avila
Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
factorize more 'incompatible options' messages, 2022-01-31) to use the
same parameterized error message for reporting incompatible command line
options. This reduces the number of strings to translate and makes the
UI slightly more consistent.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
builtin/clone.c | 4 +++-
builtin/merge-tree.c | 3 ++-
parse-options.c | 3 ++-
revision.c | 4 ++--
t/t0040-parse-options.sh | 8 ++++----
t/t1006-cat-file.sh | 2 +-
t/t4301-merge-tree-write-tree.sh | 2 +-
t/t5606-clone-options.sh | 2 +-
8 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index c6357af949..45a5070268 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -965,7 +965,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
if (bundle_uri && deepen)
- die(_("--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude"));
+ die(_("options '%s' and '%s' cannot be used together"),
+ "--bundle-uri",
+ "--depth/--shallow-since/--shallow-exclude");
repo_name = argv[0];
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index a35e0452d6..a4aa6013c5 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -577,7 +577,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
if (o.mode == MODE_TRIVIAL)
die(_("--trivial-merge is incompatible with all other options"));
if (merge_base)
- die(_("--merge-base is incompatible with --stdin"));
+ die(_("options '%s' and '%s' cannot be used together"),
+ "--merge-base", "--stdin");
line_termination = '\0';
while (strbuf_getline_lf(&buf, stdin) != EOF) {
struct strbuf **split;
diff --git a/parse-options.c b/parse-options.c
index e0c94b0546..c3955847f4 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -279,7 +279,8 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
opt_name = optnamearg(opt, arg, flags);
other_opt_name = optnamearg(elem->opt, elem->arg, elem->flags);
- error(_("%s is incompatible with %s"), opt_name, other_opt_name);
+ error(_("options '%s' and '%s' cannot be used together"),
+ opt_name, other_opt_name);
free(opt_name);
free(other_opt_name);
return -1;
diff --git a/revision.c b/revision.c
index 00d5c29bfc..b2861474b1 100644
--- a/revision.c
+++ b/revision.c
@@ -2384,8 +2384,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->left_right = 1;
} else if (!strcmp(arg, "--left-only")) {
if (revs->right_only)
- die("--left-only is incompatible with --right-only"
- " or --cherry");
+ die(_("options '%s' and '%s' cannot be used together"),
+ "--left-only", "--right-only/--cherry");
revs->left_only = 1;
} else if (!strcmp(arg, "--right-only")) {
if (revs->left_only)
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 8fdef88b65..ec974867e4 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -376,7 +376,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' '
test_must_be_empty output &&
test_grep "mode1" output.err &&
test_grep "mode2" output.err &&
- test_grep "is incompatible with" output.err
+ test_grep "cannot be used together" output.err
'
test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
@@ -384,7 +384,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
test_must_be_empty output &&
test_grep "mode2" output.err &&
test_grep "set23" output.err &&
- test_grep "is incompatible with" output.err
+ test_grep "cannot be used together" output.err
'
test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
@@ -392,7 +392,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
test_must_be_empty output &&
test_grep "mode2" output.err &&
test_grep "set23" output.err &&
- test_grep "is incompatible with" output.err
+ test_grep "cannot be used together" output.err
'
test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
@@ -401,7 +401,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
test_must_be_empty output &&
test_grep "mode2" output.err &&
test_grep "mode34.3" output.err &&
- test_grep "is incompatible with" output.err
+ test_grep "cannot be used together" output.err
'
test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
index d73a0be1b9..271c5e4fd3 100755
--- a/t/t1006-cat-file.sh
+++ b/t/t1006-cat-file.sh
@@ -6,7 +6,7 @@ test_description='git cat-file'
test_cmdmode_usage () {
test_expect_code 129 "$@" 2>err &&
- grep "^error:.*is incompatible with" err
+ grep "^error: .* cannot be used together" err
}
for switches in \
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh
index b2c8a43fce..12ac436873 100755
--- a/t/t4301-merge-tree-write-tree.sh
+++ b/t/t4301-merge-tree-write-tree.sh
@@ -887,7 +887,7 @@ test_expect_success '--stdin with both a successful and a conflicted merge' '
test_expect_success '--merge-base is incompatible with --stdin' '
test_must_fail git merge-tree --merge-base=side1 --stdin 2>expect &&
- grep "^fatal: --merge-base is incompatible with --stdin" expect
+ grep "^fatal: .*merge-base.*stdin.* cannot be used together" expect
'
# specify merge-base as parent of branch2
diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh
index fc4bbd9daf..a400bcca62 100755
--- a/t/t5606-clone-options.sh
+++ b/t/t5606-clone-options.sh
@@ -64,7 +64,7 @@ test_expect_success 'disallows --bundle-uri with shallow options' '
for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD
do
test_must_fail git clone --bundle-uri=bundle $option from to 2>err &&
- grep "bundle-uri is incompatible" err || return 1
+ grep "bundle-uri.* cannot be used together" err || return 1
done
'
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-26 11:57 [PATCH] i18n: factorize even more 'incompatible options' messages René Scharfe
@ 2023-11-26 17:49 ` Eric Sunshine
2023-11-27 17:39 ` René Scharfe
2023-12-11 8:09 ` [PATCH][RESEND] show-ref: use die_for_incompatible_opt3() René Scharfe
2023-11-27 13:11 ` [PATCH] i18n: factorize even more 'incompatible options' messages Junio C Hamano
2023-11-27 13:12 ` Junio C Hamano
2 siblings, 2 replies; 8+ messages in thread
From: Eric Sunshine @ 2023-11-26 17:49 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List, Jean-Noël Avila
On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:
> Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
> into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
> factorize more 'incompatible options' messages, 2022-01-31) to use the
> same parameterized error message for reporting incompatible command line
> options. This reduces the number of strings to translate and makes the
> UI slightly more consistent.
Thanks for tackling this.
A couple additional instances recently slipped into `show-ref.c` which
were caught during review[1,2] but nevertheless made it to
"master"[3,4]. This patch, of course, doesn't need to address those,
but if rerolling for some other reason, perhaps they can be included,
as well(?).
[1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/
[2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/
[3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of
subcommands, 2023-10-31)
[4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference
existence, 2023-10-31)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-26 11:57 [PATCH] i18n: factorize even more 'incompatible options' messages René Scharfe
2023-11-26 17:49 ` Eric Sunshine
@ 2023-11-27 13:11 ` Junio C Hamano
2023-11-27 13:12 ` Junio C Hamano
2 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2023-11-27 13:11 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List, Jean-Noël Avila
René Scharfe <l.s.r@web.de> writes:
> Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
> into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
> factorize more 'incompatible options' messages, 2022-01-31) to use the
> same parameterized error message for reporting incompatible command line
> options. This reduces the number of strings to translate and makes the
> UI slightly more consistent.
Will queue. Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-26 11:57 [PATCH] i18n: factorize even more 'incompatible options' messages René Scharfe
2023-11-26 17:49 ` Eric Sunshine
2023-11-27 13:11 ` [PATCH] i18n: factorize even more 'incompatible options' messages Junio C Hamano
@ 2023-11-27 13:12 ` Junio C Hamano
2 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2023-11-27 13:12 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List, Jean-Noël Avila
René Scharfe <l.s.r@web.de> writes:
> Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
> into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
> factorize more 'incompatible options' messages, 2022-01-31) to use the
> same parameterized error message for reporting incompatible command line
> options. This reduces the number of strings to translate and makes the
> UI slightly more consistent.
Will queue. Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-26 17:49 ` Eric Sunshine
@ 2023-11-27 17:39 ` René Scharfe
2023-11-27 17:48 ` Eric Sunshine
2023-11-28 12:33 ` Patrick Steinhardt
2023-12-11 8:09 ` [PATCH][RESEND] show-ref: use die_for_incompatible_opt3() René Scharfe
1 sibling, 2 replies; 8+ messages in thread
From: René Scharfe @ 2023-11-27 17:39 UTC (permalink / raw)
To: Eric Sunshine
Cc: Jean-Noël Avila, Patrick Steinhardt, Junio C Hamano,
Git List
Am 26.11.23 um 18:49 schrieb Eric Sunshine:
> On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:
>> Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
>> into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
>> factorize more 'incompatible options' messages, 2022-01-31) to use the
>> same parameterized error message for reporting incompatible command line
>> options. This reduces the number of strings to translate and makes the
>> UI slightly more consistent.
>
> Thanks for tackling this.
>
> A couple additional instances recently slipped into `show-ref.c` which
> were caught during review[1,2] but nevertheless made it to
> "master"[3,4]. This patch, of course, doesn't need to address those,
> but if rerolling for some other reason, perhaps they can be included,
> as well(?).
>
> [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/
> [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/
> [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of
> subcommands, 2023-10-31)
> [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference
> existence, 2023-10-31)
[4] changes the message added by [3], so that's one instance, right?
--- >8 ---
Subject: [PATCH] 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>
---
builtin/show-ref.c | 6 +++---
t/t1403-show-ref.sh | 16 +++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7aac525a87..59d2291cbf 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -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);
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index b50ae6fcf1..d477689e33 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '
'
test_expect_success 'show-ref sub-modes are mutually exclusive' '
- cat >expect <<-EOF &&
- fatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given
- EOF
-
test_must_fail git show-ref --verify --exclude-existing 2>err &&
- test_cmp expect err &&
+ grep "verify" err &&
+ grep "exclude-existing" err &&
+ grep "cannot be used together" err &&
test_must_fail git show-ref --verify --exists 2>err &&
- test_cmp expect err &&
+ grep "verify" err &&
+ grep "exists" err &&
+ grep "cannot be used together" err &&
test_must_fail git show-ref --exclude-existing --exists 2>err &&
- test_cmp expect err
+ grep "exclude-existing" err &&
+ grep "exists" err &&
+ grep "cannot be used together" err
'
test_expect_success '--exists with existing reference' '
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-27 17:39 ` René Scharfe
@ 2023-11-27 17:48 ` Eric Sunshine
2023-11-28 12:33 ` Patrick Steinhardt
1 sibling, 0 replies; 8+ messages in thread
From: Eric Sunshine @ 2023-11-27 17:48 UTC (permalink / raw)
To: René Scharfe
Cc: Jean-Noël Avila, Patrick Steinhardt, Junio C Hamano,
Git List
On Mon, Nov 27, 2023 at 12:39 PM René Scharfe <l.s.r@web.de> wrote:
> Am 26.11.23 um 18:49 schrieb Eric Sunshine:
> > A couple additional instances recently slipped into `show-ref.c` which
> > were caught during review[1,2] but nevertheless made it to
> > "master"[3,4]. This patch, of course, doesn't need to address those,
> > but if rerolling for some other reason, perhaps they can be included,
> > as well(?).
> >
> > [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/
> > [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/
> > [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of
> > subcommands, 2023-10-31)
> > [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference
> > existence, 2023-10-31)
>
> [4] changes the message added by [3], so that's one instance, right?
Yes, correct. Sorry for misleadingly saying there were two new
messages; it's been a month since I looked at the patches closely, and
forgot that it was just the single message which had been modified by
the subsequent patch.
Thanks for taking care of this so quickly!
> --- >8 ---
> Subject: [PATCH] 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.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
Apparently, I haven't been following along closely enough, thus wasn't
aware that we had the die_for_incompatible_opt*() family of functions.
Neat.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i18n: factorize even more 'incompatible options' messages
2023-11-27 17:39 ` René Scharfe
2023-11-27 17:48 ` Eric Sunshine
@ 2023-11-28 12:33 ` Patrick Steinhardt
1 sibling, 0 replies; 8+ messages in thread
From: Patrick Steinhardt @ 2023-11-28 12:33 UTC (permalink / raw)
To: René Scharfe
Cc: Eric Sunshine, Jean-Noël Avila, Junio C Hamano, Git List
[-- Attachment #1: Type: text/plain, Size: 4338 bytes --]
On Mon, Nov 27, 2023 at 06:39:41PM +0100, René Scharfe wrote:
> Am 26.11.23 um 18:49 schrieb Eric Sunshine:
> > On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:
> >> Continue the work of 12909b6b8a (i18n: turn "options are incompatible"
> >> into "cannot be used together", 2022-01-05) and a699367bb8 (i18n:
> >> factorize more 'incompatible options' messages, 2022-01-31) to use the
> >> same parameterized error message for reporting incompatible command line
> >> options. This reduces the number of strings to translate and makes the
> >> UI slightly more consistent.
> >
> > Thanks for tackling this.
> >
> > A couple additional instances recently slipped into `show-ref.c` which
> > were caught during review[1,2] but nevertheless made it to
> > "master"[3,4]. This patch, of course, doesn't need to address those,
> > but if rerolling for some other reason, perhaps they can be included,
> > as well(?).
Ah, I wasn't aware of these new wrappers, either. The below patch looks
good to me, thanks for the fixup.
Patrick
> > [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/
> > [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/
> > [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of
> > subcommands, 2023-10-31)
> > [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference
> > existence, 2023-10-31)
>
> [4] changes the message added by [3], so that's one instance, right?
>
> --- >8 ---
> Subject: [PATCH] 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>
> ---
> builtin/show-ref.c | 6 +++---
> t/t1403-show-ref.sh | 16 +++++++++-------
> 2 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/builtin/show-ref.c b/builtin/show-ref.c
> index 7aac525a87..59d2291cbf 100644
> --- a/builtin/show-ref.c
> +++ b/builtin/show-ref.c
> @@ -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);
> diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
> index b50ae6fcf1..d477689e33 100755
> --- a/t/t1403-show-ref.sh
> +++ b/t/t1403-show-ref.sh
> @@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '
> '
>
> test_expect_success 'show-ref sub-modes are mutually exclusive' '
> - cat >expect <<-EOF &&
> - fatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given
> - EOF
> -
> test_must_fail git show-ref --verify --exclude-existing 2>err &&
> - test_cmp expect err &&
> + grep "verify" err &&
> + grep "exclude-existing" err &&
> + grep "cannot be used together" err &&
>
> test_must_fail git show-ref --verify --exists 2>err &&
> - test_cmp expect err &&
> + grep "verify" err &&
> + grep "exists" err &&
> + grep "cannot be used together" err &&
>
> test_must_fail git show-ref --exclude-existing --exists 2>err &&
> - test_cmp expect err
> + grep "exclude-existing" err &&
> + grep "exists" err &&
> + grep "cannot be used together" err
> '
>
> test_expect_success '--exists with existing reference' '
> --
> 2.43.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH][RESEND] show-ref: use die_for_incompatible_opt3()
2023-11-26 17:49 ` Eric Sunshine
2023-11-27 17:39 ` René Scharfe
@ 2023-12-11 8:09 ` René Scharfe
1 sibling, 0 replies; 8+ messages in thread
From: René Scharfe @ 2023-12-11 8:09 UTC (permalink / raw)
To: Git List
Cc: Jean-Noël Avila, Patrick Steinhardt, Junio C Hamano,
Eric Sunshine
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>
---
Original submission:
https://lore.kernel.org/git/d1f28272-635d-4638-b0f4-76d64013b0d5@web.de/
builtin/show-ref.c | 6 +++---
t/t1403-show-ref.sh | 16 +++++++++-------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 7aac525a87..59d2291cbf 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -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);
diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh
index b50ae6fcf1..d477689e33 100755
--- a/t/t1403-show-ref.sh
+++ b/t/t1403-show-ref.sh
@@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '
'
test_expect_success 'show-ref sub-modes are mutually exclusive' '
- cat >expect <<-EOF &&
- fatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given
- EOF
-
test_must_fail git show-ref --verify --exclude-existing 2>err &&
- test_cmp expect err &&
+ grep "verify" err &&
+ grep "exclude-existing" err &&
+ grep "cannot be used together" err &&
test_must_fail git show-ref --verify --exists 2>err &&
- test_cmp expect err &&
+ grep "verify" err &&
+ grep "exists" err &&
+ grep "cannot be used together" err &&
test_must_fail git show-ref --exclude-existing --exists 2>err &&
- test_cmp expect err
+ grep "exclude-existing" err &&
+ grep "exists" err &&
+ grep "cannot be used together" err
'
test_expect_success '--exists with existing reference' '
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-11 8:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-26 11:57 [PATCH] i18n: factorize even more 'incompatible options' messages René Scharfe
2023-11-26 17:49 ` Eric Sunshine
2023-11-27 17:39 ` René Scharfe
2023-11-27 17:48 ` Eric Sunshine
2023-11-28 12:33 ` Patrick Steinhardt
2023-12-11 8:09 ` [PATCH][RESEND] show-ref: use die_for_incompatible_opt3() René Scharfe
2023-11-27 13:11 ` [PATCH] i18n: factorize even more 'incompatible options' messages Junio C Hamano
2023-11-27 13:12 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).