i18n: factorize "invalid value" messages
Use the same message when an invalid value is passed to a command line option or a configuration variable. Signed-off-by: Jean-Noël Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jean-Noël Avila committed
Jan 31, 2022 at 22:07 UTC
1a8aea857e4225a9d35a531869fd47777f3063d6
15 files changed
+30
-25
builtin/am.c
+5
-3
@@ -199,7 +199,7 @@ static int am_option_parse_empty(const struct option *opt,
199
else if (!strcmp(arg, "keep"))
200
*opt_value = KEEP_EMPTY_COMMIT;
201
else
202
- return error(_("Invalid value for --empty: %s"), arg);
202
+ return error(_("invalid value for '%s': '%s'"), "--empty", arg);
203
204
return 0;
205
}
@@ -2239,7 +2239,8 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
2239
* when you add new options
2240
*/
2241
else
2242
- return error(_("Invalid value for --patch-format: %s"), arg);
2242
+ return error(_("invalid value for '%s': '%s'"),
2243
+ "--patch-format", arg);
2244
return 0;
2245
}
2246
@@ -2282,7 +2283,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
2283
break;
2284
}
2285
if (new_value >= ARRAY_SIZE(valid_modes))
2285
- return error(_("Invalid value for --show-current-patch: %s"), arg);
2286
+ return error(_("invalid value for '%s': '%s'"),
2287
+ "--show-current-patch", arg);
2288
}
2289
2290
if (resume->mode == RESUME_SHOW_PATCH && new_value != resume->sub_mode)
builtin/blame.c
+4
-3
@@ -721,8 +721,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
721
}
722
if (!strcmp(var, "color.blame.repeatedlines")) {
723
if (color_parse_mem(value, strlen(value), repeated_meta_color))
724
- warning(_("invalid color '%s' in color.blame.repeatedLines"),
725
- value);
724
+ warning(_("invalid value for '%s': '%s'"),
725
+ "color.blame.repeatedLines", value);
726
return 0;
727
}
728
if (!strcmp(var, "color.blame.highlightrecent")) {
@@ -739,7 +739,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
739
coloring_mode &= ~(OUTPUT_COLOR_LINE |
740
OUTPUT_SHOW_AGE_WITH_COLOR);
741
} else {
742
- warning(_("invalid value for blame.coloring"));
742
+ warning(_("invalid value for '%s': '%s'"),
743
+ "blame.coloring", value);
744
return 0;
745
}
746
}
builtin/fetch.c
+2
-2
@@ -763,8 +763,8 @@ static void prepare_format_display(struct ref *ref_map)
763
else if (!strcasecmp(format, "compact"))
764
compact_format = 1;
765
else
766
- die(_("configuration fetch.output contains invalid value %s"),
767
- format);
766
+ die(_("invalid value for '%s': '%s'"),
767
+ "fetch.output", format);
768
769
for (rm = ref_map; rm; rm = rm->next) {
770
if (rm->status == REF_STATUS_REJECT_SHALLOW ||
builtin/pack-objects.c
+1
-1
@@ -3504,7 +3504,7 @@ static int option_parse_missing_action(const struct option *opt,
3504
return 0;
3505
}
3506
3507
- die(_("invalid value for --missing"));
3507
+ die(_("invalid value for '%s': '%s'"), "--missing", arg);
3508
return 0;
3509
}
3510
builtin/pull.c
+3
-3
@@ -42,9 +42,9 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
42
return v;
43
44
if (fatal)
45
- die(_("Invalid value for %s: %s"), key, value);
45
+ die(_("invalid value for '%s': '%s'"), key, value);
46
else
47
- error(_("Invalid value for %s: %s"), key, value);
47
+ error(_("invalid value for '%s': '%s'"), key, value);
48
49
return REBASE_INVALID;
50
}
@@ -318,7 +318,7 @@ static const char *config_get_ff(void)
318
if (!strcmp(value, "only"))
319
return "--ff-only";
320
321
- die(_("Invalid value for pull.ff: %s"), value);
321
+ die(_("invalid value for '%s': '%s'"), "pull.ff", value);
322
}
323
324
/**
builtin/push.c
+1
-1
@@ -486,7 +486,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
486
if (value && !strcasecmp(value, "if-asked"))
487
set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED);
488
else
489
- return error("Invalid value for '%s'", k);
489
+ return error(_("invalid value for '%s'"), k);
490
}
491
}
492
} else if (!strcmp(k, "push.recursesubmodules")) {
builtin/send-pack.c
+1
-1
@@ -145,7 +145,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
145
if (value && !strcasecmp(value, "if-asked"))
146
args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
147
else
148
- return error("Invalid value for '%s'", k);
148
+ return error(_("invalid value for '%s'"), k);
149
}
150
}
151
}
diff-merges.c
+1
-1
@@ -67,7 +67,7 @@ static void set_diff_merges(struct rev_info *revs, const char *optarg)
67
diff_merges_setup_func_t func = func_by_opt(optarg);
68
69
if (!func)
70
- die(_("unknown value for --diff-merges: %s"), optarg);
70
+ die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg);
71
72
func(revs);
73
gpg-interface.c
+3
-3
@@ -702,7 +702,7 @@ int git_gpg_config(const char *var, const char *value, void *cb)
702
return config_error_nonbool(var);
703
fmt = get_format_by_name(value);
704
if (!fmt)
705
- return error("unsupported value for %s: %s",
705
+ return error(_("invalid value for '%s': '%s'"),
706
var, value);
707
use_format = fmt;
708
return 0;
@@ -717,8 +717,8 @@ int git_gpg_config(const char *var, const char *value, void *cb)
717
free(trust);
718
719
if (ret)
720
- return error("unsupported value for %s: %s", var,
721
- value);
720
+ return error(_("invalid value for '%s': '%s'"),
721
+ var, value);
722
return 0;
723
}
724
ls-refs.c
+2
-1
@@ -34,7 +34,8 @@ static void ensure_config_read(void)
34
} else if (!strcmp(str, "ignore")) {
35
/* do nothing */
36
} else {
37
- die(_("invalid value '%s' for lsrefs.unborn"), str);
37
+ die(_("invalid value for '%s': '%s'"),
38
+ "lsrefs.unborn", str);
39
}
40
}
41
config_read = 1;
parallel-checkout.c
+2
-2
@@ -39,8 +39,8 @@ void get_parallel_checkout_configs(int *num_workers, int *threshold)
39
40
if (env_workers && *env_workers) {
41
if (strtol_i(env_workers, 10, num_workers)) {
42
- die("invalid value for GIT_TEST_CHECKOUT_WORKERS: '%s'",
43
- env_workers);
42
+ die(_("invalid value for '%s': '%s'"),
43
+ "GIT_TEST_CHECKOUT_WORKERS", env_workers);
44
}
45
if (*num_workers < 1)
46
*num_workers = online_cpus();
sequencer.c
+1
-1
@@ -2806,7 +2806,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
2806
return error(_("invalid key: %s"), key);
2807
2808
if (!error_flag)
2809
- return error(_("invalid value for %s: %s"), key, value);
2809
+ return error(_("invalid value for '%s': '%s'"), key, value);
2810
2811
return 0;
2812
}
setup.c
+2
-1
@@ -559,7 +559,8 @@ static enum extension_result handle_extension(const char *var,
559
return config_error_nonbool(var);
560
format = hash_algo_by_name(value);
561
if (format == GIT_HASH_UNKNOWN)
562
- return error("invalid value for 'extensions.objectformat'");
562
+ return error(_("invalid value for '%s': '%s'"),
563
+ "extensions.objectformat", value);
564
data->hash_algo = format;
565
return EXTENSION_OK;
566
}
submodule-config.c
+1
-1
@@ -496,7 +496,7 @@ static int parse_config(const char *var, const char *value, void *data)
496
else if (parse_submodule_update_strategy(value,
497
&submodule->update_strategy) < 0 ||
498
submodule->update_strategy.type == SM_UPDATE_COMMAND)
499
- die(_("invalid value for %s"), var);
499
+ die(_("invalid value for '%s'"), var);
500
} else if (!strcmp(item.buf, "shallow")) {
501
if (!me->overwrite && submodule->recommend_shallow != -1)
502
warn_multiple_config(me->treeish_name, submodule->name,
t/t4150-am.sh
+1
-1
@@ -1169,7 +1169,7 @@ test_expect_success 'invalid when passing the --empty option alone' '
1169
test_when_finished "git am --abort || :" &&
1170
git checkout empty-commit^ &&
1171
test_must_fail git am --empty empty-commit.patch 2>err &&
1172
- echo "error: Invalid value for --empty: empty-commit.patch" >expected &&
1172
+ echo "error: invalid value for '\''--empty'\'': '\''empty-commit.patch'\''" >expected &&
1173
test_cmp expected err
1174
'
1175