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. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Nov 26, 2023 at 12:57 UTC
7854bf49604484a7276b96d312b9daf7d15c7b34
8 files changed
+16
-12
builtin/clone.c
+3
-1
@@ -965,7 +965,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
965
}
966
967
if (bundle_uri && deepen)
968
- die(_("--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude"));
968
+ die(_("options '%s' and '%s' cannot be used together"),
969
+ "--bundle-uri",
970
+ "--depth/--shallow-since/--shallow-exclude");
971
972
repo_name = argv[0];
973
builtin/merge-tree.c
+2
-1
@@ -577,7 +577,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
577
if (o.mode == MODE_TRIVIAL)
578
die(_("--trivial-merge is incompatible with all other options"));
579
if (merge_base)
580
- die(_("--merge-base is incompatible with --stdin"));
580
+ die(_("options '%s' and '%s' cannot be used together"),
581
+ "--merge-base", "--stdin");
582
line_termination = '\0';
583
while (strbuf_getline_lf(&buf, stdin) != EOF) {
584
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,
279
280
opt_name = optnamearg(opt, arg, flags);
281
other_opt_name = optnamearg(elem->opt, elem->arg, elem->flags);
282
- error(_("%s is incompatible with %s"), opt_name, other_opt_name);
282
+ error(_("options '%s' and '%s' cannot be used together"),
283
+ opt_name, other_opt_name);
284
free(opt_name);
285
free(other_opt_name);
286
return -1;
revision.c
+2
-2
@@ -2384,8 +2384,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
2384
revs->left_right = 1;
2385
} else if (!strcmp(arg, "--left-only")) {
2386
if (revs->right_only)
2387
- die("--left-only is incompatible with --right-only"
2388
- " or --cherry");
2387
+ die(_("options '%s' and '%s' cannot be used together"),
2388
+ "--left-only", "--right-only/--cherry");
2389
revs->left_only = 1;
2390
} else if (!strcmp(arg, "--right-only")) {
2391
if (revs->left_only)
t/t0040-parse-options.sh
+4
-4
@@ -376,7 +376,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' '
376
test_must_be_empty output &&
377
test_grep "mode1" output.err &&
378
test_grep "mode2" output.err &&
379
- test_grep "is incompatible with" output.err
379
+ test_grep "cannot be used together" output.err
380
'
381
382
test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
@@ -384,7 +384,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
384
test_must_be_empty output &&
385
test_grep "mode2" output.err &&
386
test_grep "set23" output.err &&
387
- test_grep "is incompatible with" output.err
387
+ test_grep "cannot be used together" output.err
388
'
389
390
test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
@@ -392,7 +392,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
392
test_must_be_empty output &&
393
test_grep "mode2" output.err &&
394
test_grep "set23" output.err &&
395
- test_grep "is incompatible with" output.err
395
+ test_grep "cannot be used together" output.err
396
'
397
398
test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
@@ -401,7 +401,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
401
test_must_be_empty output &&
402
test_grep "mode2" output.err &&
403
test_grep "mode34.3" output.err &&
404
- test_grep "is incompatible with" output.err
404
+ test_grep "cannot be used together" output.err
405
'
406
407
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'
6
7
test_cmdmode_usage () {
8
test_expect_code 129 "$@" 2>err &&
9
- grep "^error:.*is incompatible with" err
9
+ grep "^error: .* cannot be used together" err
10
}
11
12
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' '
887
test_expect_success '--merge-base is incompatible with --stdin' '
888
test_must_fail git merge-tree --merge-base=side1 --stdin 2>expect &&
889
890
- grep "^fatal: --merge-base is incompatible with --stdin" expect
890
+ grep "^fatal: .*merge-base.*stdin.* cannot be used together" expect
891
'
892
893
# 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' '
64
for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD
65
do
66
test_must_fail git clone --bundle-uri=bundle $option from to 2>err &&
67
- grep "bundle-uri is incompatible" err || return 1
67
+ grep "bundle-uri.* cannot be used together" err || return 1
68
done
69
'
70