{"thread":{"id":"60561","subject":"[PATCH] i18n: factorize even more 'incompatible options' messages","startedAt":"2023-11-26T11:57:45Z","lastAt":"2023-12-11T08:14:46Z","messageCount":8,"participants":["René Scharfe","Eric Sunshine","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"485158","messageId":"e6eb12e4-bb63-473c-9c2f-965a4d5981ad@web.de","threadId":"60561","inReplyTo":null,"subject":"[PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2023-11-26T11:57:43Z","receivedAt":"2023-11-26T11:57:45Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\ninto \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\nfactorize more 'incompatible options' messages, 2022-01-31) to use the\nsame parameterized error message for reporting incompatible command line\noptions.  This reduces the number of strings to translate and makes the\nUI slightly more consistent.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/clone.c                  | 4 +++-\n builtin/merge-tree.c             | 3 ++-\n parse-options.c                  | 3 ++-\n revision.c                       | 4 ++--\n t/t0040-parse-options.sh         | 8 ++++----\n t/t1006-cat-file.sh              | 2 +-\n t/t4301-merge-tree-write-tree.sh | 2 +-\n t/t5606-clone-options.sh         | 2 +-\n 8 files changed, 16 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex c6357af949..45a5070268 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -965,7 +965,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t}\n\n \tif (bundle_uri && deepen)\n-\t\tdie(_(\"--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude\"));\n+\t\tdie(_(\"options '%s' and '%s' cannot be used together\"),\n+\t\t    \"--bundle-uri\",\n+\t\t    \"--depth/--shallow-since/--shallow-exclude\");\n\n \trepo_name = argv[0];\n\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex a35e0452d6..a4aa6013c5 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -577,7 +577,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)\n \t\tif (o.mode == MODE_TRIVIAL)\n \t\t\tdie(_(\"--trivial-merge is incompatible with all other options\"));\n \t\tif (merge_base)\n-\t\t\tdie(_(\"--merge-base is incompatible with --stdin\"));\n+\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"),\n+\t\t\t    \"--merge-base\", \"--stdin\");\n \t\tline_termination = '\\0';\n \t\twhile (strbuf_getline_lf(&buf, stdin) != EOF) {\n \t\t\tstruct strbuf **split;\ndiff --git a/parse-options.c b/parse-options.c\nindex e0c94b0546..c3955847f4 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -279,7 +279,8 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,\n\n \topt_name = optnamearg(opt, arg, flags);\n \tother_opt_name = optnamearg(elem->opt, elem->arg, elem->flags);\n-\terror(_(\"%s is incompatible with %s\"), opt_name, other_opt_name);\n+\terror(_(\"options '%s' and '%s' cannot be used together\"),\n+\t      opt_name, other_opt_name);\n \tfree(opt_name);\n \tfree(other_opt_name);\n \treturn -1;\ndiff --git a/revision.c b/revision.c\nindex 00d5c29bfc..b2861474b1 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2384,8 +2384,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->left_right = 1;\n \t} else if (!strcmp(arg, \"--left-only\")) {\n \t\tif (revs->right_only)\n-\t\t\tdie(\"--left-only is incompatible with --right-only\"\n-\t\t\t    \" or --cherry\");\n+\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"),\n+\t\t\t    \"--left-only\", \"--right-only/--cherry\");\n \t\trevs->left_only = 1;\n \t} else if (!strcmp(arg, \"--right-only\")) {\n \t\tif (revs->left_only)\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex 8fdef88b65..ec974867e4 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -376,7 +376,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' '\n \ttest_must_be_empty output &&\n \ttest_grep \"mode1\" output.err &&\n \ttest_grep \"mode2\" output.err &&\n-\ttest_grep \"is incompatible with\" output.err\n+\ttest_grep \"cannot be used together\" output.err\n '\n\n test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '\n@@ -384,7 +384,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '\n \ttest_must_be_empty output &&\n \ttest_grep \"mode2\" output.err &&\n \ttest_grep \"set23\" output.err &&\n-\ttest_grep \"is incompatible with\" output.err\n+\ttest_grep \"cannot be used together\" output.err\n '\n\n test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '\n@@ -392,7 +392,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '\n \ttest_must_be_empty output &&\n \ttest_grep \"mode2\" output.err &&\n \ttest_grep \"set23\" output.err &&\n-\ttest_grep \"is incompatible with\" output.err\n+\ttest_grep \"cannot be used together\" output.err\n '\n\n test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '\n@@ -401,7 +401,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '\n \ttest_must_be_empty output &&\n \ttest_grep \"mode2\" output.err &&\n \ttest_grep \"mode34.3\" output.err &&\n-\ttest_grep \"is incompatible with\" output.err\n+\ttest_grep \"cannot be used together\" output.err\n '\n\n test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '\ndiff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh\nindex d73a0be1b9..271c5e4fd3 100755\n--- a/t/t1006-cat-file.sh\n+++ b/t/t1006-cat-file.sh\n@@ -6,7 +6,7 @@ test_description='git cat-file'\n\n test_cmdmode_usage () {\n \ttest_expect_code 129 \"$@\" 2>err &&\n-\tgrep \"^error:.*is incompatible with\" err\n+\tgrep \"^error: .* cannot be used together\" err\n }\n\n for switches in \\\ndiff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh\nindex b2c8a43fce..12ac436873 100755\n--- a/t/t4301-merge-tree-write-tree.sh\n+++ b/t/t4301-merge-tree-write-tree.sh\n@@ -887,7 +887,7 @@ test_expect_success '--stdin with both a successful and a conflicted merge' '\n test_expect_success '--merge-base is incompatible with --stdin' '\n \ttest_must_fail git merge-tree --merge-base=side1 --stdin 2>expect &&\n\n-\tgrep \"^fatal: --merge-base is incompatible with --stdin\" expect\n+\tgrep \"^fatal: .*merge-base.*stdin.* cannot be used together\" expect\n '\n\n # specify merge-base as parent of branch2\ndiff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh\nindex fc4bbd9daf..a400bcca62 100755\n--- a/t/t5606-clone-options.sh\n+++ b/t/t5606-clone-options.sh\n@@ -64,7 +64,7 @@ test_expect_success 'disallows --bundle-uri with shallow options' '\n \tfor option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD\n \tdo\n \t\ttest_must_fail git clone --bundle-uri=bundle $option from to 2>err &&\n-\t\tgrep \"bundle-uri is incompatible\" err || return 1\n+\t\tgrep \"bundle-uri.* cannot be used together\" err || return 1\n \tdone\n '\n\n--\n2.43.0\n"},{"id":"485160","messageId":"CAPig+cR5PKkyC24LkOU4+yzng1xeBOBbADTBHXH61xkAR7kymw@mail.gmail.com","threadId":"60561","inReplyTo":"e6eb12e4-bb63-473c-9c2f-965a4d5981ad@web.de","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2023-11-26T17:49:13Z","receivedAt":"2023-11-26T17:49:25Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:\n> Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\n> into \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\n> factorize more 'incompatible options' messages, 2022-01-31) to use the\n> same parameterized error message for reporting incompatible command line\n> options.  This reduces the number of strings to translate and makes the\n> UI slightly more consistent.\n\nThanks for tackling this.\n\nA couple additional instances recently slipped into `show-ref.c` which\nwere caught during review[1,2] but nevertheless made it to\n\"master\"[3,4]. This patch, of course, doesn't need to address those,\nbut if rerolling for some other reason, perhaps they can be included,\nas well(?).\n\n[1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/\n[2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/\n[3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of\nsubcommands, 2023-10-31)\n[4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference\nexistence, 2023-10-31)\n"},{"id":"485168","messageId":"xmqqttp71gtj.fsf@gitster.g","threadId":"60561","inReplyTo":"e6eb12e4-bb63-473c-9c2f-965a4d5981ad@web.de","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-11-27T13:11:52Z","receivedAt":"2023-11-27T13:12:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\n> into \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\n> factorize more 'incompatible options' messages, 2022-01-31) to use the\n> same parameterized error message for reporting incompatible command line\n> options.  This reduces the number of strings to translate and makes the\n> UI slightly more consistent.\n\nWill queue.  Thanks.\n"},{"id":"485169","messageId":"xmqqo7ff1gsm.fsf@gitster.g","threadId":"60561","inReplyTo":"e6eb12e4-bb63-473c-9c2f-965a4d5981ad@web.de","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-11-27T13:12:25Z","receivedAt":"2023-11-27T13:12:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\n> into \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\n> factorize more 'incompatible options' messages, 2022-01-31) to use the\n> same parameterized error message for reporting incompatible command line\n> options.  This reduces the number of strings to translate and makes the\n> UI slightly more consistent.\n\nWill queue.  Thanks.\n"},{"id":"485174","messageId":"d1f28272-635d-4638-b0f4-76d64013b0d5@web.de","threadId":"60561","inReplyTo":"CAPig+cR5PKkyC24LkOU4+yzng1xeBOBbADTBHXH61xkAR7kymw@mail.gmail.com","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2023-11-27T17:39:41Z","receivedAt":"2023-11-27T17:39:53Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 26.11.23 um 18:49 schrieb Eric Sunshine:\n> On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:\n>> Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\n>> into \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\n>> factorize more 'incompatible options' messages, 2022-01-31) to use the\n>> same parameterized error message for reporting incompatible command line\n>> options.  This reduces the number of strings to translate and makes the\n>> UI slightly more consistent.\n>\n> Thanks for tackling this.\n>\n> A couple additional instances recently slipped into `show-ref.c` which\n> were caught during review[1,2] but nevertheless made it to\n> \"master\"[3,4]. This patch, of course, doesn't need to address those,\n> but if rerolling for some other reason, perhaps they can be included,\n> as well(?).\n>\n> [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/\n> [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/\n> [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of\n> subcommands, 2023-10-31)\n> [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference\n> existence, 2023-10-31)\n\n[4] changes the message added by [3], so that's one instance, right?\n\n--- >8 ---\nSubject: [PATCH] show-ref: use die_for_incompatible_opt3()\n\nUse the standard message for reporting the use of multiple mutually\nexclusive options by calling die_for_incompatible_opt3() instead of\nrolling our own.  This has the benefits of showing only the actually\ngiven options, reducing the number of strings to translate and making\nthe UI slightly more consistent.\n\nAdjust the test to no longer insist on a specific order of the\nreported options, as this implementation detail does not affect the\nusefulness of the error message.\n\nReported-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n builtin/show-ref.c  |  6 +++---\n t/t1403-show-ref.sh | 16 +++++++++-------\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 7aac525a87..59d2291cbf 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -315,9 +315,9 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, show_ref_options,\n \t\t\t     show_ref_usage, 0);\n\n-\tif ((!!exclude_existing_opts.enabled + !!verify + !!exists) > 1)\n-\t\tdie(_(\"only one of '%s', '%s' or '%s' can be given\"),\n-\t\t    \"--exclude-existing\", \"--verify\", \"--exists\");\n+\tdie_for_incompatible_opt3(exclude_existing_opts.enabled, \"--exclude-existing\",\n+\t\t\t\t  verify, \"--verify\",\n+\t\t\t\t  exists, \"--exists\");\n\n \tif (exclude_existing_opts.enabled)\n \t\treturn cmd_show_ref__exclude_existing(&exclude_existing_opts);\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex b50ae6fcf1..d477689e33 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '\n '\n\n test_expect_success 'show-ref sub-modes are mutually exclusive' '\n-\tcat >expect <<-EOF &&\n-\tfatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given\n-\tEOF\n-\n \ttest_must_fail git show-ref --verify --exclude-existing 2>err &&\n-\ttest_cmp expect err &&\n+\tgrep \"verify\" err &&\n+\tgrep \"exclude-existing\" err &&\n+\tgrep \"cannot be used together\" err &&\n\n \ttest_must_fail git show-ref --verify --exists 2>err &&\n-\ttest_cmp expect err &&\n+\tgrep \"verify\" err &&\n+\tgrep \"exists\" err &&\n+\tgrep \"cannot be used together\" err &&\n\n \ttest_must_fail git show-ref --exclude-existing --exists 2>err &&\n-\ttest_cmp expect err\n+\tgrep \"exclude-existing\" err &&\n+\tgrep \"exists\" err &&\n+\tgrep \"cannot be used together\" err\n '\n\n test_expect_success '--exists with existing reference' '\n--\n2.43.0\n"},{"id":"485175","messageId":"CAPig+cR_SN5yJbNQC8F6--hhTj-5_KW97WVszFDOfub=R_OeZQ@mail.gmail.com","threadId":"60561","inReplyTo":"d1f28272-635d-4638-b0f4-76d64013b0d5@web.de","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2023-11-27T17:48:30Z","receivedAt":"2023-11-27T17:48:42Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 27, 2023 at 12:39 PM René Scharfe <l.s.r@web.de> wrote:\n> Am 26.11.23 um 18:49 schrieb Eric Sunshine:\n> > A couple additional instances recently slipped into `show-ref.c` which\n> > were caught during review[1,2] but nevertheless made it to\n> > \"master\"[3,4]. This patch, of course, doesn't need to address those,\n> > but if rerolling for some other reason, perhaps they can be included,\n> > as well(?).\n> >\n> > [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/\n> > [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/\n> > [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of\n> > subcommands, 2023-10-31)\n> > [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference\n> > existence, 2023-10-31)\n>\n> [4] changes the message added by [3], so that's one instance, right?\n\nYes, correct. Sorry for misleadingly saying there were two new\nmessages; it's been a month since I looked at the patches closely, and\nforgot that it was just the single message which had been modified by\nthe subsequent patch.\n\nThanks for taking care of this so quickly!\n\n> --- >8 ---\n> Subject: [PATCH] show-ref: use die_for_incompatible_opt3()\n>\n> Use the standard message for reporting the use of multiple mutually\n> exclusive options by calling die_for_incompatible_opt3() instead of\n> rolling our own.  This has the benefits of showing only the actually\n> given options, reducing the number of strings to translate and making\n> the UI slightly more consistent.\n>\n> Adjust the test to no longer insist on a specific order of the\n> reported options, as this implementation detail does not affect the\n> usefulness of the error message.\n>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n\nApparently, I haven't been following along closely enough, thus wasn't\naware that we had the die_for_incompatible_opt*() family of functions.\nNeat.\n"},{"id":"485191","messageId":"ZWXeKYHOCbwEOvnR@tanuki","threadId":"60561","inReplyTo":"d1f28272-635d-4638-b0f4-76d64013b0d5@web.de","subject":"Re: [PATCH] i18n: factorize even more 'incompatible options' messages","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-11-28T12:33:45Z","receivedAt":"2023-11-28T12:33:51Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Nov 27, 2023 at 06:39:41PM +0100, René Scharfe wrote:\n> Am 26.11.23 um 18:49 schrieb Eric Sunshine:\n> > On Sun, Nov 26, 2023 at 6:57 AM René Scharfe <l.s.r@web.de> wrote:\n> >> Continue the work of 12909b6b8a (i18n: turn \"options are incompatible\"\n> >> into \"cannot be used together\", 2022-01-05) and a699367bb8 (i18n:\n> >> factorize more 'incompatible options' messages, 2022-01-31) to use the\n> >> same parameterized error message for reporting incompatible command line\n> >> options.  This reduces the number of strings to translate and makes the\n> >> UI slightly more consistent.\n> >\n> > Thanks for tackling this.\n> >\n> > A couple additional instances recently slipped into `show-ref.c` which\n> > were caught during review[1,2] but nevertheless made it to\n> > \"master\"[3,4]. This patch, of course, doesn't need to address those,\n> > but if rerolling for some other reason, perhaps they can be included,\n> > as well(?).\n\nAh, I wasn't aware of these new wrappers, either. The below patch looks\ngood to me, thanks for the fixup.\n\nPatrick\n\n> > [1]: https://lore.kernel.org/git/CAPig+cSrp7vZuy7D_ENHKZKZzF4OSmCtfYNHPGMtS1Hj6gArDw@mail.gmail.com/\n> > [2]: https://lore.kernel.org/git/CAPig+cRTOMie0rUf=Mhbo9e2EXf-_2kQyMeqpB9OCRB1MZZ1rw@mail.gmail.com/\n> > [3]: 199970e72f (builtin/show-ref: ensure mutual exclusiveness of\n> > subcommands, 2023-10-31)\n> > [4]: 9080a7f178 (builtin/show-ref: add new mode to check for reference\n> > existence, 2023-10-31)\n> \n> [4] changes the message added by [3], so that's one instance, right?\n> \n> --- >8 ---\n> Subject: [PATCH] show-ref: use die_for_incompatible_opt3()\n> \n> Use the standard message for reporting the use of multiple mutually\n> exclusive options by calling die_for_incompatible_opt3() instead of\n> rolling our own.  This has the benefits of showing only the actually\n> given options, reducing the number of strings to translate and making\n> the UI slightly more consistent.\n> \n> Adjust the test to no longer insist on a specific order of the\n> reported options, as this implementation detail does not affect the\n> usefulness of the error message.\n> \n> Reported-by: Eric Sunshine <sunshine@sunshineco.com>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  builtin/show-ref.c  |  6 +++---\n>  t/t1403-show-ref.sh | 16 +++++++++-------\n>  2 files changed, 12 insertions(+), 10 deletions(-)\n> \n> diff --git a/builtin/show-ref.c b/builtin/show-ref.c\n> index 7aac525a87..59d2291cbf 100644\n> --- a/builtin/show-ref.c\n> +++ b/builtin/show-ref.c\n> @@ -315,9 +315,9 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)\n>  \targc = parse_options(argc, argv, prefix, show_ref_options,\n>  \t\t\t     show_ref_usage, 0);\n> \n> -\tif ((!!exclude_existing_opts.enabled + !!verify + !!exists) > 1)\n> -\t\tdie(_(\"only one of '%s', '%s' or '%s' can be given\"),\n> -\t\t    \"--exclude-existing\", \"--verify\", \"--exists\");\n> +\tdie_for_incompatible_opt3(exclude_existing_opts.enabled, \"--exclude-existing\",\n> +\t\t\t\t  verify, \"--verify\",\n> +\t\t\t\t  exists, \"--exists\");\n> \n>  \tif (exclude_existing_opts.enabled)\n>  \t\treturn cmd_show_ref__exclude_existing(&exclude_existing_opts);\n> diff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\n> index b50ae6fcf1..d477689e33 100755\n> --- a/t/t1403-show-ref.sh\n> +++ b/t/t1403-show-ref.sh\n> @@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '\n>  '\n> \n>  test_expect_success 'show-ref sub-modes are mutually exclusive' '\n> -\tcat >expect <<-EOF &&\n> -\tfatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given\n> -\tEOF\n> -\n>  \ttest_must_fail git show-ref --verify --exclude-existing 2>err &&\n> -\ttest_cmp expect err &&\n> +\tgrep \"verify\" err &&\n> +\tgrep \"exclude-existing\" err &&\n> +\tgrep \"cannot be used together\" err &&\n> \n>  \ttest_must_fail git show-ref --verify --exists 2>err &&\n> -\ttest_cmp expect err &&\n> +\tgrep \"verify\" err &&\n> +\tgrep \"exists\" err &&\n> +\tgrep \"cannot be used together\" err &&\n> \n>  \ttest_must_fail git show-ref --exclude-existing --exists 2>err &&\n> -\ttest_cmp expect err\n> +\tgrep \"exclude-existing\" err &&\n> +\tgrep \"exists\" err &&\n> +\tgrep \"cannot be used together\" err\n>  '\n> \n>  test_expect_success '--exists with existing reference' '\n> --\n> 2.43.0\n"},{"id":"485513","messageId":"e5304253-3347-4900-bbf2-d3c6ee3fb976@web.de","threadId":"60561","inReplyTo":"CAPig+cR5PKkyC24LkOU4+yzng1xeBOBbADTBHXH61xkAR7kymw@mail.gmail.com","subject":"[PATCH][RESEND] show-ref: use die_for_incompatible_opt3()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2023-12-11T08:09:28Z","receivedAt":"2023-12-11T08:14:46Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Use the standard message for reporting the use of multiple mutually\nexclusive options by calling die_for_incompatible_opt3() instead of\nrolling our own.  This has the benefits of showing only the actually\ngiven options, reducing the number of strings to translate and making\nthe UI slightly more consistent.\n\nAdjust the test to no longer insist on a specific order of the\nreported options, as this implementation detail does not affect the\nusefulness of the error message.\n\nReported-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: René Scharfe <l.s.r@web.de>\nReviewed-by: Patrick Steinhardt <ps@pks.im>\n---\nOriginal submission:\nhttps://lore.kernel.org/git/d1f28272-635d-4638-b0f4-76d64013b0d5@web.de/\n\n builtin/show-ref.c  |  6 +++---\n t/t1403-show-ref.sh | 16 +++++++++-------\n 2 files changed, 12 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 7aac525a87..59d2291cbf 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -315,9 +315,9 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, show_ref_options,\n \t\t\t     show_ref_usage, 0);\n\n-\tif ((!!exclude_existing_opts.enabled + !!verify + !!exists) > 1)\n-\t\tdie(_(\"only one of '%s', '%s' or '%s' can be given\"),\n-\t\t    \"--exclude-existing\", \"--verify\", \"--exists\");\n+\tdie_for_incompatible_opt3(exclude_existing_opts.enabled, \"--exclude-existing\",\n+\t\t\t\t  verify, \"--verify\",\n+\t\t\t\t  exists, \"--exists\");\n\n \tif (exclude_existing_opts.enabled)\n \t\treturn cmd_show_ref__exclude_existing(&exclude_existing_opts);\ndiff --git a/t/t1403-show-ref.sh b/t/t1403-show-ref.sh\nindex b50ae6fcf1..d477689e33 100755\n--- a/t/t1403-show-ref.sh\n+++ b/t/t1403-show-ref.sh\n@@ -197,18 +197,20 @@ test_expect_success 'show-ref --verify with dangling ref' '\n '\n\n test_expect_success 'show-ref sub-modes are mutually exclusive' '\n-\tcat >expect <<-EOF &&\n-\tfatal: only one of ${SQ}--exclude-existing${SQ}, ${SQ}--verify${SQ} or ${SQ}--exists${SQ} can be given\n-\tEOF\n-\n \ttest_must_fail git show-ref --verify --exclude-existing 2>err &&\n-\ttest_cmp expect err &&\n+\tgrep \"verify\" err &&\n+\tgrep \"exclude-existing\" err &&\n+\tgrep \"cannot be used together\" err &&\n\n \ttest_must_fail git show-ref --verify --exists 2>err &&\n-\ttest_cmp expect err &&\n+\tgrep \"verify\" err &&\n+\tgrep \"exists\" err &&\n+\tgrep \"cannot be used together\" err &&\n\n \ttest_must_fail git show-ref --exclude-existing --exists 2>err &&\n-\ttest_cmp expect err\n+\tgrep \"exclude-existing\" err &&\n+\tgrep \"exists\" err &&\n+\tgrep \"cannot be used together\" err\n '\n\n test_expect_success '--exists with existing reference' '\n--\n2.43.0\n"}]}