i18n: factorize even more 'incompatible options' messages
PATCH 1/1 i18n: factorize even more 'incompatible options' messages
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.
--- 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(-)
builtin/clone.c +3 -1
@@ -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 ];
builtin/merge-tree.c +2 -1
@@ -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;
parse-options.c +2 -1
@@ -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 ;
revision.c +2 -2
@@ -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)
t/t0040-parse-options.sh +4 -4
@@ -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' '
t/t1006-cat-file.sh +1 -1
@@ -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 \
t/t4301-merge-tree-write-tree.sh +1 -1
@@ -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
t/t5606-clone-options.sh +1 -1
@@ -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
Quoted 6 lines · René Scharfe
Continue the work of
12909b6b8a(i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) anda699367bb8(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)
Am 26.11.23 um 18:49 schrieb Eric Sunshine:
Quoted 16 lines · René Scharfe
Quoted 6 lines
Continue the work of
12909b6b8a(i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) anda699367bb8(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.cwhich 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(?).
Quoted 6 lines
[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.
--- builtin/show-ref.c | 6 +++--- t/t1403-show-ref.sh | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-)
builtin/show-ref.c +3 -3
@@ -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);
t/t1403-show-ref.sh +9 -7
@@ -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
Quoted 7 lines · René Scharfe
Am 26.11.23 um 18:49 schrieb Eric Sunshine:
Quoted 6 lines
A couple additional instances recently slipped into
show-ref.cwhich 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(?).
Quoted 8 lines
Quoted 6 lines
[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!
Quoted 9 lines
--- >8 ---
Subject: [PATCH] show-ref: usedie_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.
Quoted 5 lines
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 <[email protected]>
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.
Quoted 16 lines · René Scharfe
Am 26.11.23 um 18:49 schrieb Eric Sunshine:
Quoted 15 lines · René Scharfe
Quoted 6 lines
Continue the work of
12909b6b8a(i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) anda699367bb8(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.cwhich 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
Quoted 80 lines
Quoted 6 lines
[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: usedie_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 <[email protected]>Signed-off-by René Scharfe <[email protected]>--- builtin/show-ref.c | 6 +++--- t/t1403-show-ref.sh | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-)builtin/show-ref.c +3
-3@@ -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);t/t1403-show-ref.sh +9
-8@@ -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
PATCH RESEND 1/1 show-ref: use die_for_incompatible_opt3()
In reply to Eric SunshineUse 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.
---
Original submission:
https://lore.kernel.org/git/[email protected]/
builtin/show-ref.c | 6 +++--- t/t1403-show-ref.sh | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-)
builtin/show-ref.c +3 -3
@@ -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);
t/t1403-show-ref.sh +9 -7
@@ -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
Quoted 6 lines · René Scharfe
Continue the work of
12909b6b8a(i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) anda699367bb8(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.
Quoted 6 lines · René Scharfe
Continue the work of
12909b6b8a(i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) anda699367bb8(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.