]> git.ipfire.org Git - thirdparty/git.git/commitdiff
i18n: factorize "invalid value" messages
authorJean-Noël Avila <jn.avila@free.fr>
Mon, 31 Jan 2022 22:07:47 +0000 (22:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 4 Feb 2022 21:58:28 +0000 (13:58 -0800)
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>
15 files changed:
builtin/am.c
builtin/blame.c
builtin/fetch.c
builtin/pack-objects.c
builtin/pull.c
builtin/push.c
builtin/send-pack.c
diff-merges.c
gpg-interface.c
ls-refs.c
parallel-checkout.c
sequencer.c
setup.c
submodule-config.c
t/t4150-am.sh

index b6be1f1cb11e47dcb1012e1afe60fbae654f25cd..97dbeb8e49e9058e225c1e15b9b7fba24681693c 100644 (file)
@@ -199,7 +199,7 @@ static int am_option_parse_empty(const struct option *opt,
        else if (!strcmp(arg, "keep"))
                *opt_value = KEEP_EMPTY_COMMIT;
        else
-               return error(_("Invalid value for --empty: %s"), arg);
+               return error(_("invalid value for '%s': '%s'"), "--empty", arg);
 
        return 0;
 }
@@ -2239,7 +2239,8 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
         * when you add new options
         */
        else
-               return error(_("Invalid value for --patch-format: %s"), arg);
+               return error(_("invalid value for '%s': '%s'"),
+                            "--patch-format", arg);
        return 0;
 }
 
@@ -2282,7 +2283,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
                                break;
                }
                if (new_value >= ARRAY_SIZE(valid_modes))
-                       return error(_("Invalid value for --show-current-patch: %s"), arg);
+                       return error(_("invalid value for '%s': '%s'"),
+                                    "--show-current-patch", arg);
        }
 
        if (resume->mode == RESUME_SHOW_PATCH && new_value != resume->sub_mode)
index 7fafeac408141bb89e5c69512c3a7f174729e4dd..9c142f17a2e9d77485af9db8a9a65f2f014e3f62 100644 (file)
@@ -721,8 +721,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
        }
        if (!strcmp(var, "color.blame.repeatedlines")) {
                if (color_parse_mem(value, strlen(value), repeated_meta_color))
-                       warning(_("invalid color '%s' in color.blame.repeatedLines"),
-                               value);
+                       warning(_("invalid value for '%s': '%s'"),
+                               "color.blame.repeatedLines", value);
                return 0;
        }
        if (!strcmp(var, "color.blame.highlightrecent")) {
@@ -739,7 +739,8 @@ static int git_blame_config(const char *var, const char *value, void *cb)
                        coloring_mode &= ~(OUTPUT_COLOR_LINE |
                                            OUTPUT_SHOW_AGE_WITH_COLOR);
                } else {
-                       warning(_("invalid value for blame.coloring"));
+                       warning(_("invalid value for '%s': '%s'"),
+                               "blame.coloring", value);
                        return 0;
                }
        }
index 5f06b21f8e97c5459fdb558302c5b9b95e99eee8..8be19bb8799bc40bd3c2d93274e0021eefc1f107 100644 (file)
@@ -763,8 +763,8 @@ static void prepare_format_display(struct ref *ref_map)
        else if (!strcasecmp(format, "compact"))
                compact_format = 1;
        else
-               die(_("configuration fetch.output contains invalid value %s"),
-                   format);
+               die(_("invalid value for '%s': '%s'"),
+                   "fetch.output", format);
 
        for (rm = ref_map; rm; rm = rm->next) {
                if (rm->status == REF_STATUS_REJECT_SHALLOW ||
index ba2006f2212bea19b202ba3db155b345bf7fbb89..192c3ca305ec5e47ded429c407c5c1a97ec13ba9 100644 (file)
@@ -3504,7 +3504,7 @@ static int option_parse_missing_action(const struct option *opt,
                return 0;
        }
 
-       die(_("invalid value for --missing"));
+       die(_("invalid value for '%s': '%s'"), "--missing", arg);
        return 0;
 }
 
index 100cbf9fb85b59fee6a8f9f90ced02c9abdaac6e..e54a0ccadc6c318dcf45c05a1cd438bebf382cf4 100644 (file)
@@ -42,9 +42,9 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
                return v;
 
        if (fatal)
-               die(_("Invalid value for %s: %s"), key, value);
+               die(_("invalid value for '%s': '%s'"), key, value);
        else
-               error(_("Invalid value for %s: %s"), key, value);
+               error(_("invalid value for '%s': '%s'"), key, value);
 
        return REBASE_INVALID;
 }
@@ -318,7 +318,7 @@ static const char *config_get_ff(void)
        if (!strcmp(value, "only"))
                return "--ff-only";
 
-       die(_("Invalid value for pull.ff: %s"), value);
+       die(_("invalid value for '%s': '%s'"), "pull.ff", value);
 }
 
 /**
index 359db90321c31ea27aa9160f08d21b89179ca488..cad997965a7fb73d757f7a74570b634cbc9408e9 100644 (file)
@@ -486,7 +486,7 @@ static int git_push_config(const char *k, const char *v, void *cb)
                                if (value && !strcasecmp(value, "if-asked"))
                                        set_push_cert_flags(flags, SEND_PACK_PUSH_CERT_IF_ASKED);
                                else
-                                       return error("Invalid value for '%s'", k);
+                                       return error(_("invalid value for '%s'"), k);
                        }
                }
        } else if (!strcmp(k, "push.recursesubmodules")) {
index 69c432ef1a6272c12f6c71558c973eecd3796c90..64962be016825a47acddf374cd6ebf80db163af0 100644 (file)
@@ -145,7 +145,7 @@ static int send_pack_config(const char *k, const char *v, void *cb)
                                if (value && !strcasecmp(value, "if-asked"))
                                        args.push_cert = SEND_PACK_PUSH_CERT_IF_ASKED;
                                else
-                                       return error("Invalid value for '%s'", k);
+                                       return error(_("invalid value for '%s'"), k);
                        }
                }
        }
index 5060ccd890bd307b1276e367e3b70872718e3af7..cd6c102a0d59b3f969222e49c368ff0499b0db1a 100644 (file)
@@ -67,7 +67,7 @@ static void set_diff_merges(struct rev_info *revs, const char *optarg)
        diff_merges_setup_func_t func = func_by_opt(optarg);
 
        if (!func)
-               die(_("unknown value for --diff-merges: %s"), optarg);
+               die(_("invalid value for '%s': '%s'"), "--diff-merges", optarg);
 
        func(revs);
 
index b52eb0e2e04b37c6868f7573d750b688a4ec0e68..4e084b08f67d24ce8c3bad52ab05d68667c39e94 100644 (file)
@@ -702,7 +702,7 @@ int git_gpg_config(const char *var, const char *value, void *cb)
                        return config_error_nonbool(var);
                fmt = get_format_by_name(value);
                if (!fmt)
-                       return error("unsupported value for %s: %s",
+                       return error(_("invalid value for '%s': '%s'"),
                                     var, value);
                use_format = fmt;
                return 0;
@@ -717,8 +717,8 @@ int git_gpg_config(const char *var, const char *value, void *cb)
                free(trust);
 
                if (ret)
-                       return error("unsupported value for %s: %s", var,
-                                    value);
+                       return error(_("invalid value for '%s': '%s'"),
+                                    var, value);
                return 0;
        }
 
index 54078323dcb92b68463e6c16b23621ae8f47a2f1..98e69373c8404ead982595fc9dbda5c4fe8137a1 100644 (file)
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -34,7 +34,8 @@ static void ensure_config_read(void)
                } else if (!strcmp(str, "ignore")) {
                        /* do nothing */
                } else {
-                       die(_("invalid value '%s' for lsrefs.unborn"), str);
+                       die(_("invalid value for '%s': '%s'"),
+                           "lsrefs.unborn", str);
                }
        }
        config_read = 1;
index 8dd7e7bad404321856c43cfcbe9a7fbab4fd9ebe..31a3d0ee1bf851792c21bc3a9ef52fc33d9e5637 100644 (file)
@@ -39,8 +39,8 @@ void get_parallel_checkout_configs(int *num_workers, int *threshold)
 
        if (env_workers && *env_workers) {
                if (strtol_i(env_workers, 10, num_workers)) {
-                       die("invalid value for GIT_TEST_CHECKOUT_WORKERS: '%s'",
-                           env_workers);
+                       die(_("invalid value for '%s': '%s'"),
+                           "GIT_TEST_CHECKOUT_WORKERS", env_workers);
                }
                if (*num_workers < 1)
                        *num_workers = online_cpus();
index 5213d16e97174adbf10fc487edb0f3d3a726f7d7..683f5392ebaefac8545d27eef17d5101ff082a43 100644 (file)
@@ -2806,7 +2806,7 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
                return error(_("invalid key: %s"), key);
 
        if (!error_flag)
-               return error(_("invalid value for %s: %s"), key, value);
+               return error(_("invalid value for '%s': '%s'"), key, value);
 
        return 0;
 }
diff --git a/setup.c b/setup.c
index af3b8c09abe398edd0f45828b81ecec72b3900b6..04ce33cdcd4a94b7e0050d6beba20aaa478c6eda 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -559,7 +559,8 @@ static enum extension_result handle_extension(const char *var,
                        return config_error_nonbool(var);
                format = hash_algo_by_name(value);
                if (format == GIT_HASH_UNKNOWN)
-                       return error("invalid value for 'extensions.objectformat'");
+                       return error(_("invalid value for '%s': '%s'"),
+                                    "extensions.objectformat", value);
                data->hash_algo = format;
                return EXTENSION_OK;
        }
index f95344028b5208cc9808382b9c69975d8a692682..fb95a026f4898437a96f759032679c0a905bc7af 100644 (file)
@@ -496,7 +496,7 @@ static int parse_config(const char *var, const char *value, void *data)
                else if (parse_submodule_update_strategy(value,
                         &submodule->update_strategy) < 0 ||
                         submodule->update_strategy.type == SM_UPDATE_COMMAND)
-                       die(_("invalid value for %s"), var);
+                       die(_("invalid value for '%s'"), var);
        } else if (!strcmp(item.buf, "shallow")) {
                if (!me->overwrite && submodule->recommend_shallow != -1)
                        warn_multiple_config(me->treeish_name, submodule->name,
index 6caff0ca397e442d9d053c0ed1a7808e74bcbfe4..159fae8d0162a3d1f0543d28a9817f156b45df5c 100755 (executable)
@@ -1169,7 +1169,7 @@ test_expect_success 'invalid when passing the --empty option alone' '
        test_when_finished "git am --abort || :" &&
        git checkout empty-commit^ &&
        test_must_fail git am --empty empty-commit.patch 2>err &&
-       echo "error: Invalid value for --empty: empty-commit.patch" >expected &&
+       echo "error: invalid value for '\''--empty'\'': '\''empty-commit.patch'\''" >expected &&
        test_cmp expected err
 '