Skip to content

Commit 1a8aea8

Browse files
jnavilagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a699367 commit 1a8aea8

15 files changed

+30
-25
lines changed

builtin/am.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int am_option_parse_empty(const struct option *opt,
199199
else if (!strcmp(arg, "keep"))
200200
*opt_value = KEEP_EMPTY_COMMIT;
201201
else
202-
return error(_("Invalid value for --empty: %s"), arg);
202+
return error(_("invalid value for '%s': '%s'"), "--empty", arg);
203203

204204
return 0;
205205
}
@@ -2239,7 +2239,8 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
22392239
* when you add new options
22402240
*/
22412241
else
2242-
return error(_("Invalid value for --patch-format: %s"), arg);
2242+
return error(_("invalid value for '%s': '%s'"),
2243+
"--patch-format", arg);
22432244
return 0;
22442245
}
22452246

@@ -2282,7 +2283,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
22822283
break;
22832284
}
22842285
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);
22862288
}
22872289

22882290
if (resume->mode == RESUME_SHOW_PATCH && new_value != resume->sub_mode)

builtin/blame.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
721721
}
722722
if (!strcmp(var, "color.blame.repeatedlines")) {
723723
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);
726726
return 0;
727727
}
728728
if (!strcmp(var, "color.blame.highlightrecent")) {
@@ -739,7 +739,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
739739
coloring_mode &= ~(OUTPUT_COLOR_LINE |
740740
OUTPUT_SHOW_AGE_WITH_COLOR);
741741
} else {
742-
warning(_("invalid value for blame.coloring"));
742+
warning(_("invalid value for '%s': '%s'"),
743+
"blame.coloring", value);
743744
return 0;
744745
}
745746
}

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,8 @@ static void prepare_format_display(struct ref *ref_map)
763763
else if (!strcasecmp(format, "compact"))
764764
compact_format = 1;
765765
else
766-
die(_("configuration fetch.output contains invalid value %s"),
767-
format);
766+
die(_("invalid value for '%s': '%s'"),
767+
"fetch.output", format);
768768

769769
for (rm = ref_map; rm; rm = rm->next) {
770770
if (rm->status == REF_STATUS_REJECT_SHALLOW ||

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3504,7 +3504,7 @@ static int option_parse_missing_action(const struct option *opt,
35043504
return 0;
35053505
}
35063506

3507-
die(_("invalid value for --missing"));
3507+
die(_("invalid value for '%s': '%s'"), "--missing", arg);
35083508
return 0;
35093509
}
35103510

builtin/pull.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
4242
return v;
4343

4444
if (fatal)
45-
die(_("Invalid value for %s: %s"), key, value);
45+
die(_("invalid value for '%s': '%s'"), key, value);
4646
else
47-
error(_("Invalid value for %s: %s"), key, value);
47+
error(_("invalid value for '%s': '%s'"), key, value);
4848

4949
return REBASE_INVALID;
5050
}
@@ -318,7 +318,7 @@ static const char *config_get_ff(void)
318318
if (!strcmp(value, "only"))
319319
return "--ff-only";
320320

321-
die(_("Invalid value for pull.ff: %s"), value);
321+
die(_("invalid value for '%s': '%s'"), "pull.ff", value);
322322
}
323323

324324
/**

builtin/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
486486
if (value && !strcasecmp(value, "if-asked"))
487487
set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED);
488488
else
489-
return error("Invalid value for '%s'", k);
489+
return error(_("invalid value for '%s'"), k);
490490
}
491491
}
492492
} else if (!strcmp(k, "push.recursesubmodules")) {

builtin/send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
145145
if (value && !strcasecmp(value, "if-asked"))
146146
args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
147147
else
148-
return error("Invalid value for '%s'", k);
148+
return error(_("invalid value for '%s'"), k);
149149
}
150150
}
151151
}

diff-merges.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void set_diff_merges(struct rev_info *revs, const char *optarg)
6767
diff_merges_setup_func_t func = func_by_opt(optarg);
6868

6969
if (!func)
70-
die(_("unknown value for --diff-merges: %s"), optarg);
70+
die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg);
7171

7272
func(revs);
7373

gpg-interface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ int git_gpg_config(const char *var, const char *value, void *cb)
702702
return config_error_nonbool(var);
703703
fmt = get_format_by_name(value);
704704
if (!fmt)
705-
return error("unsupported value for %s: %s",
705+
return error(_("invalid value for '%s': '%s'"),
706706
var, value);
707707
use_format = fmt;
708708
return 0;
@@ -717,8 +717,8 @@ int git_gpg_config(const char *var, const char *value, void *cb)
717717
free(trust);
718718

719719
if (ret)
720-
return error("unsupported value for %s: %s", var,
721-
value);
720+
return error(_("invalid value for '%s': '%s'"),
721+
var, value);
722722
return 0;
723723
}
724724

ls-refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ static void ensure_config_read(void)
3434
} else if (!strcmp(str, "ignore")) {
3535
/* do nothing */
3636
} else {
37-
die(_("invalid value '%s' for lsrefs.unborn"), str);
37+
die(_("invalid value for '%s': '%s'"),
38+
"lsrefs.unborn", str);
3839
}
3940
}
4041
config_read = 1;

0 commit comments

Comments
 (0)