Skip to content

Commit 7854bf4

Browse files
rscharfegitster
authored andcommitted
i18n: factorize even more 'incompatible options' messages
Continue the work of 12909b6 (i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) and a699367 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 564d025 commit 7854bf4

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
965965
}
966966

967967
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");
969971

970972
repo_name = argv[0];
971973

builtin/merge-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
577577
if (o.mode == MODE_TRIVIAL)
578578
die(_("--trivial-merge is incompatible with all other options"));
579579
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");
581582
line_termination = '\0';
582583
while (strbuf_getline_lf(&buf, stdin) != EOF) {
583584
struct strbuf **split;

parse-options.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
279279

280280
opt_name = optnamearg(opt, arg, flags);
281281
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);
283284
free(opt_name);
284285
free(other_opt_name);
285286
return -1;

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,8 +2384,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
23842384
revs->left_right = 1;
23852385
} else if (!strcmp(arg, "--left-only")) {
23862386
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");
23892389
revs->left_only = 1;
23902390
} else if (!strcmp(arg, "--right-only")) {
23912391
if (revs->left_only)

t/t0040-parse-options.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,23 +376,23 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' '
376376
test_must_be_empty output &&
377377
test_grep "mode1" output.err &&
378378
test_grep "mode2" output.err &&
379-
test_grep "is incompatible with" output.err
379+
test_grep "cannot be used together" output.err
380380
'
381381

382382
test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' '
383383
test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err &&
384384
test_must_be_empty output &&
385385
test_grep "mode2" output.err &&
386386
test_grep "set23" output.err &&
387-
test_grep "is incompatible with" output.err
387+
test_grep "cannot be used together" output.err
388388
'
389389

390390
test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' '
391391
test_must_fail test-tool parse-options --mode2 --set23 >output 2>output.err &&
392392
test_must_be_empty output &&
393393
test_grep "mode2" output.err &&
394394
test_grep "set23" output.err &&
395-
test_grep "is incompatible with" output.err
395+
test_grep "cannot be used together" output.err
396396
'
397397

398398
test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
@@ -401,7 +401,7 @@ test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' '
401401
test_must_be_empty output &&
402402
test_grep "mode2" output.err &&
403403
test_grep "mode34.3" output.err &&
404-
test_grep "is incompatible with" output.err
404+
test_grep "cannot be used together" output.err
405405
'
406406

407407
test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '

t/t1006-cat-file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test_description='git cat-file'
66

77
test_cmdmode_usage () {
88
test_expect_code 129 "$@" 2>err &&
9-
grep "^error:.*is incompatible with" err
9+
grep "^error: .* cannot be used together" err
1010
}
1111

1212
for switches in \

t/t4301-merge-tree-write-tree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ test_expect_success '--stdin with both a successful and a conflicted merge' '
887887
test_expect_success '--merge-base is incompatible with --stdin' '
888888
test_must_fail git merge-tree --merge-base=side1 --stdin 2>expect &&
889889
890-
grep "^fatal: --merge-base is incompatible with --stdin" expect
890+
grep "^fatal: .*merge-base.*stdin.* cannot be used together" expect
891891
'
892892

893893
# specify merge-base as parent of branch2

t/t5606-clone-options.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test_expect_success 'disallows --bundle-uri with shallow options' '
6464
for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD
6565
do
6666
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
6868
done
6969
'
7070

0 commit comments

Comments
 (0)