i18n: turn even more messages into "cannot be used together" ones

Even if some of these messages are not subject to gettext i18n, this helps bring a single style of message for a given error type. Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Reviewed-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jean-Noël Avila committed Jan 5, 2022 at 20:02 UTC 246cac85055f513626159e8cd20b741eaf5f9f97
23 files changed +47 -41
builtin/add.c
+1 -1
@@ -566,7 +566,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
566
567 if (pathspec_from_file) {
568 if (pathspec.nr)
569 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
569 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
570
571 parse_pathspec_file(&pathspec, PATHSPEC_ATTR,
572 PATHSPEC_PREFER_FULL |
builtin/am.c
+3 -3
@@ -2230,9 +2230,9 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
2230 }
2231
2232 if (resume->mode == RESUME_SHOW_PATCH && new_value != resume->sub_mode)
2233 - return error(_("--show-current-patch=%s is incompatible with "
2234 - "--show-current-patch=%s"),
2235 - arg, valid_modes[resume->sub_mode]);
2233 + return error(_("options '%s=%s' and '%s=%s' "
2234 + "cannot be used together"),
2235 + "--show-current-patch", "--show-current-patch", arg, valid_modes[resume->sub_mode]);
2236
2237 resume->mode = RESUME_SHOW_PATCH;
2238 resume->sub_mode = new_value;
builtin/cat-file.c
+1 -1
@@ -729,7 +729,7 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
729 }
730
731 if (force_path && batch.enabled) {
732 - error("--path=<path> incompatible with --batch");
732 + error("options '--path=<path>' and '--batch' cannot be used together");
733 usage_with_options(cat_file_usage, options);
734 }
735
builtin/checkout.c
+3 -3
@@ -1635,8 +1635,8 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
1635 }
1636
1637 if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1)
1638 - die(_("-%c, -%c and --orphan are mutually exclusive"),
1639 - cb_option, toupper(cb_option));
1638 + die(_("options '-%c', '-%c', and '%s' cannot be used together"),
1639 + cb_option, toupper(cb_option), "--orphan");
1640
1641 if (opts->overlay_mode == 1 && opts->patch_mode)
1642 die(_("options '%s' and '%s' cannot be used together"), "-p", "--overlay");
@@ -1746,7 +1746,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
1746
1747 if (opts->pathspec_from_file) {
1748 if (opts->pathspec.nr)
1749 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
1749 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
1750
1751 if (opts->force_detach)
1752 die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--detach");
builtin/clone.c
+2 -2
@@ -900,8 +900,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
900
901 if (option_bare) {
902 if (option_origin)
903 - die(_("--bare and --origin %s options are incompatible."),
904 - option_origin);
903 + die(_("options '%s' and '%s %s' cannot be used together"),
904 + "--bare", "--origin", option_origin);
905 if (real_git_dir)
906 die(_("options '%s' and '%s' cannot be used together"), "--bare", "--separate-git-dir");
907 option_no_checkout = 1;
builtin/commit.c
+5 -4
@@ -361,7 +361,7 @@ static const char *prepare_index(const char **argv, const char *prefix,
361 die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "-a");
362
363 if (pathspec.nr)
364 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
364 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
365
366 parse_pathspec_file(&pathspec, 0,
367 PATHSPEC_PREFER_FULL,
@@ -799,7 +799,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
799
800 if (!strcmp(fixup_prefix, "amend")) {
801 if (have_option_m)
802 - die(_("cannot combine -m with --fixup:%s"), fixup_message);
802 + die(_("options '%s' and '%s:%s' cannot be used together"), "-m", "--fixup", fixup_message);
803 prepare_amend_commit(commit, &sb, &ctx);
804 }
805 } else if (!stat(git_path_merge_msg(the_repository), &statbuf)) {
@@ -1229,9 +1229,10 @@ static void check_fixup_reword_options(int argc, const char *argv[]) {
1229 die(_("You are in the middle of a cherry-pick -- cannot reword."));
1230 }
1231 if (argc)
1232 - die(_("cannot combine reword option of --fixup with path '%s'"), *argv);
1232 + die(_("reword option of '%s' and path '%s' cannot be used together"), "--fixup", *argv);
1233 if (patch_interactive || interactive || all || also || only)
1234 - die(_("reword option of --fixup is mutually exclusive with --patch/--interactive/--all/--include/--only"));
1234 + die(_("reword option of '%s' and '%s' cannot be used together"),
1235 + "--fixup", "--patch/--interactive/--all/--include/--only");
1236 }
1237
1238 static int parse_and_validate_options(int argc, const char *argv[],
builtin/describe.c
+2 -2
@@ -670,9 +670,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
670 }
671 describe("HEAD", 1);
672 } else if (dirty) {
673 - die(_("--dirty is incompatible with commit-ishes"));
673 + die(_("option '%s' and commit-ishes cannot be used together"), "--dirty");
674 } else if (broken) {
675 - die(_("--broken is incompatible with commit-ishes"));
675 + die(_("option '%s' and commit-ishes cannot be used together"), "--broken");
676 } else {
677 while (argc-- > 0)
678 describe(*argv++, argc == 0);
builtin/rebase.c
+2 -2
@@ -1460,8 +1460,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1460
1461 if (i >= 0) {
1462 if (is_merge(&options))
1463 - die(_("cannot combine apply options with "
1464 - "merge options"));
1463 + die(_("apply options and merge options "
1464 + "cannot be used together"));
1465 else
1466 options.type = REBASE_APPLY;
1467 }
builtin/reset.c
+1 -1
@@ -426,7 +426,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
426 die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--patch");
427
428 if (pathspec.nr)
429 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
429 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
430
431 parse_pathspec_file(&pathspec, 0,
432 PATHSPEC_PREFER_FULL,
builtin/rev-list.c
+1 -1
@@ -676,7 +676,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
676 if (revs.count &&
677 (revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
678 (revs.left_right || revs.cherry_mark))
679 - die(_("marked counting is incompatible with --objects"));
679 + die(_("marked counting and '%s' cannot be used together"), "--objects");
680
681 save_commit_buffer = (revs.verbose_header ||
682 revs.grep_filter.pattern_list ||
builtin/rm.c
+1 -1
@@ -272,7 +272,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
272
273 if (pathspec_from_file) {
274 if (pathspec.nr)
275 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
275 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
276
277 parse_pathspec_file(&pathspec, 0,
278 PATHSPEC_PREFER_CWD,
builtin/stash.c
+1 -1
@@ -1706,7 +1706,7 @@ static int push_stash(int argc, const char **argv, const char *prefix,
1706 die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--staged");
1707
1708 if (ps.nr)
1709 - die(_("--pathspec-from-file is incompatible with pathspec arguments"));
1709 + die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
1710
1711 parse_pathspec_file(&ps, 0,
1712 PATHSPEC_PREFER_FULL | PATHSPEC_PREFIX_ORIGIN,
diff.c
+8 -4
@@ -4639,16 +4639,20 @@ void diff_setup_done(struct diff_options *options)
4639 options->set_default(options);
4640
4641 if (HAS_MULTI_BITS(options->output_format & check_mask))
4642 - die(_("--name-only, --name-status, --check and -s are mutually exclusive"));
4642 + die(_("options '%s', '%s', '%s', and '%s' cannot be used together"),
4643 + "--name-only", "--name-status", "--check", "-s");
4644
4645 if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
4645 - die(_("options '%s', '%s', and '%s' cannot be used together"), "-G", "-S", "--find-object");
4646 + die(_("options '%s', '%s', and '%s' cannot be used together"),
4647 + "-G", "-S", "--find-object");
4648
4649 if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_G_REGEX_MASK))
4648 - die(_("-G and --pickaxe-regex are mutually exclusive, use --pickaxe-regex with -S"));
4650 + die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s'"),
4651 + "-G", "--pickaxe-regex", "--pickaxe-regex", "-S");
4652
4653 if (HAS_MULTI_BITS(options->pickaxe_opts & DIFF_PICKAXE_KINDS_ALL_OBJFIND_MASK))
4651 - die(_("--pickaxe-all and --find-object are mutually exclusive, use --pickaxe-all with -G and -S"));
4654 + die(_("options '%s' and '%s' cannot be used together, use '%s' with '%s' and '%s'"),
4655 + "--pickaxe-all", "--find-object", "--pickaxe-all", "-G", "-S");
4656
4657 /*
4658 * Most of the time we can say "there are changes"
t/t2026-checkout-pathspec-file.sh
+1 -1
@@ -155,7 +155,7 @@ test_expect_success 'error conditions' '
155 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
156
157 test_must_fail git checkout --pathspec-from-file=list -- fileA.t 2>err &&
158 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
158 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
159
160 test_must_fail git checkout --pathspec-file-nul 2>err &&
161 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err
t/t2072-restore-pathspec-file.sh
+1 -1
@@ -155,7 +155,7 @@ test_expect_success 'error conditions' '
155 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
156
157 test_must_fail git restore --pathspec-from-file=list --source=HEAD^1 -- fileA.t 2>err &&
158 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
158 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
159
160 test_must_fail git restore --pathspec-file-nul --source=HEAD^1 2>err &&
161 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
t/t3601-rm-pathspec-file.sh
+1 -1
@@ -67,7 +67,7 @@ test_expect_success 'error conditions' '
67 echo fileA.t >list &&
68
69 test_must_fail git rm --pathspec-from-file=list -- fileA.t 2>err &&
70 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
70 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
71
72 test_must_fail git rm --pathspec-file-nul 2>err &&
73 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
t/t3704-add-pathspec-file.sh
+1 -1
@@ -147,7 +147,7 @@ test_expect_success 'error conditions' '
147 test_i18ngrep -e "options .--pathspec-from-file. and .--edit. cannot be used together" err &&
148
149 test_must_fail git add --pathspec-from-file=list -- fileA.t 2>err &&
150 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
150 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
151
152 test_must_fail git add --pathspec-file-nul 2>err &&
153 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
t/t3909-stash-pathspec-file.sh
+1 -1
@@ -91,7 +91,7 @@ test_expect_success 'error conditions' '
91 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
92
93 test_must_fail git stash push --pathspec-from-file=list -- fileA.t 2>err &&
94 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
94 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
95
96 test_must_fail git stash push --pathspec-file-nul 2>err &&
97 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err
t/t4209-log-pickaxe.sh
+2 -2
@@ -72,12 +72,12 @@ test_expect_success 'usage' '
72 grep "cannot be used together" err &&
73
74 test_expect_code 128 git log --pickaxe-all --find-object=HEAD 2>err &&
75 - grep "mutually exclusive" err
75 + grep "cannot be used together" err
76 '
77
78 test_expect_success 'usage: --pickaxe-regex' '
79 test_expect_code 128 git log -Gregex --pickaxe-regex 2>err &&
80 - grep "mutually exclusive" err
80 + grep "cannot be used together" err
81 '
82
83 test_expect_success 'usage: --no-pickaxe-regex' '
t/t5606-clone-options.sh
+1 -1
@@ -46,7 +46,7 @@ test_expect_success 'disallows --bare with --origin' '
46
47 test_must_fail git clone -o foo --bare parent clone-bare-o 2>err &&
48 test_debug "cat err" &&
49 - test_i18ngrep -e "--bare and --origin foo options are incompatible" err
49 + test_i18ngrep -e "options .--bare. and .--origin foo. cannot be used together" err
50
51 '
52
t/t7107-reset-pathspec-file.sh
+1 -1
@@ -163,7 +163,7 @@ test_expect_success 'error conditions' '
163 test_i18ngrep -e "options .--pathspec-from-file. and .--patch. cannot be used together" err &&
164
165 test_must_fail git reset --pathspec-from-file=list -- fileA.t 2>err &&
166 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
166 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
167
168 test_must_fail git reset --pathspec-file-nul 2>err &&
169 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
t/t7500-commit-template-squash-signoff.sh
+6 -5
@@ -359,14 +359,14 @@ test_expect_success '--fixup=reword: ignores staged changes' '
359
360 test_expect_success '--fixup=reword: error out with -m option' '
361 commit_for_rebase_autosquash_setup &&
362 - echo "fatal: cannot combine -m with --fixup:reword" >expect &&
362 + echo "fatal: options '\''-m'\'' and '\''--fixup:reword'\'' cannot be used together" >expect &&
363 test_must_fail git commit --fixup=reword:HEAD~ -m "reword commit message" 2>actual &&
364 test_cmp expect actual
365 '
366
367 test_expect_success '--fixup=amend: error out with -m option' '
368 commit_for_rebase_autosquash_setup &&
369 - echo "fatal: cannot combine -m with --fixup:amend" >expect &&
369 + echo "fatal: options '\''-m'\'' and '\''--fixup:amend'\'' cannot be used together" >expect &&
370 test_must_fail git commit --fixup=amend:HEAD~ -m "amend commit message" 2>actual &&
371 test_cmp expect actual
372 '
@@ -421,8 +421,9 @@ test_expect_success 'amend! commit allows empty commit msg body with --allow-emp
421
422 test_fixup_reword_opt () {
423 test_expect_success "--fixup=reword: incompatible with $1" "
424 - echo 'fatal: reword option of --fixup is mutually exclusive with'\
425 - '--patch/--interactive/--all/--include/--only' >expect &&
424 + echo 'fatal: reword option of '\''--fixup'\'' and' \
425 + ''\''--patch/--interactive/--all/--include/--only'\' \
426 + 'cannot be used together' >expect &&
427 test_must_fail git commit --fixup=reword:HEAD~ $1 2>actual &&
428 test_cmp expect actual
429 "
@@ -435,7 +436,7 @@ done
436
437 test_expect_success '--fixup=reword: give error with pathsec' '
438 commit_for_rebase_autosquash_setup &&
438 - echo "fatal: cannot combine reword option of --fixup with path '\''foo'\''" >expect &&
439 + echo "fatal: reword option of '\''--fixup'\'' and path '\''foo'\'' cannot be used together" >expect &&
440 test_must_fail git commit --fixup=reword:HEAD~ -- foo 2>actual &&
441 test_cmp expect actual
442 '
t/t7526-commit-pathspec-file.sh
+1 -1
@@ -150,7 +150,7 @@ test_expect_success 'error conditions' '
150 test_i18ngrep -e "options .--pathspec-from-file. and .-a. cannot be used together" err &&
151
152 test_must_fail git commit --pathspec-from-file=list -m "Commit" -- fileA.t 2>err &&
153 - test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err &&
153 + test_i18ngrep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
154
155 test_must_fail git commit --pathspec-file-nul -m "Commit" 2>err &&
156 test_i18ngrep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&