Nguyễn Thái Ngọc Duy <[email protected]> writes:
> static void check_argc(int argc, int min, int max) {
> if (argc >= min && argc <= max)
> return;
> - error("wrong number of arguments");
> + if (min == max)
> + error("wrong number of arguments, should be %d", min);
> + else
> + error("wrong number of arguments, should be from %d to %d",
> + min, max);
> usage_with_options(builtin_config_usage, builtin_config_options);
> }
Good. This was the only instance of
> - some messages are improved to give more information
I spotted.
> @@ -622,7 +626,7 @@ int cmd_config(int argc, const char **argv, const char
> *prefix)
> * location; error out even if XDG_CONFIG_HOME
> * is set and points at a sane location.
> */
> - die("$HOME not set");
> + die("$HOME is not set");
Meh. There are many verb-less messages e.g. "only one X at a time"
that are not given a new verb in this patch.
> @@ -819,7 +823,7 @@ int cmd_config(int argc, const char **argv, const char
> *prefix)
> if (ret < 0)
> return ret;
> if (ret == 0)
> - die("No such section!");
> + die("no such section: %s", argv[0]);
> }
> else if (actions == ACTION_REMOVE_SECTION) {
> int ret;
> @@ -830,7 +834,7 @@ int cmd_config(int argc, const char **argv, const char
> *prefix)
> if (ret < 0)
> return ret;
> if (ret == 0)
> - die("No such section!");
> + die("no such section: %s", argv[0]);
> }
There are check_argc() calls before these two hunks to ensure that
access to argv[0] is safe, so these are good.
> @@ -2638,7 +2638,7 @@ static void read_object_list_from_stdin(void)
> if (feof(stdin))
> break;
> if (!ferror(stdin))
> - die("fgets returned NULL, not EOF, not error!");
> + die("BUG: fgets returned NULL, not EOF, not
> error!");
This is not BUG("...") because it is not *our* bug but a bug in platform's
stdio?
> @@ -456,10 +456,10 @@ static int create_graft(int argc, const char **argv,
> int force, int gentle)
> return -1;
> }
>
> - if (remove_signature(&buf)) {
> - warning(_("the original commit '%s' has a gpg signature."),
> old_ref);
> - warning(_("the signature will be removed in the replacement
> commit!"));
> - }
> + if (remove_signature(&buf))
> + warning(_("the original commit '%s' has a gpg signature.\n"
> + "The signature will be removed in the replacement
> commit!"),
> + old_ref);
Unlike a compound sentence, for which translators may appreciate
that they can reorder the parts of it to suit their language, I do
not see why these two independent sentences should be placed in a
single warning().
Or is this primarily about avoiding repeated appearance of
"warning:" labels, i.e.
warning: sentence one
warning: sentence two
I am not sure if these belong to this "simple mechanical conversion
or otherwise uncontrovercial improvement" series.
> diff --git a/config.c b/config.c
> index f4a208a166..6ba07989f1 100644
> --- a/config.c
> +++ b/config.c
> @@ -461,7 +461,7 @@ int git_config_from_parameters(config_fn_t fn, void *data)
> envw = xstrdup(env);
>
> if (sq_dequote_to_argv(envw, &argv, &nr, &alloc) < 0) {
> - ret = error("bogus format in " CONFIG_DATA_ENVIRONMENT);
> + ret = error("bogus format in %s", CONFIG_DATA_ENVIRONMENT);
> goto out;
> }
>
Good job spotting that the original wanted to say, but failed to
say, that CONFIG_DATA_ENVIRONMENT as the source of broken data we
detected. But I am not sure CONFIG_DATA_ENVIRONMENT is what we want
to report as the source of bad data to the end users. One-shot
configuration we get form "git -c VAR=VAL" are placed in the
environment as an internal implementation detail, so from their
point of view, the place we saw broken data coming from is their
command line "git -c VAR=VAL" one-shot configuration.
> @@ -1409,11 +1409,11 @@ static int git_default_push_config(const char *var,
> const char *value)
> push_default = PUSH_DEFAULT_UPSTREAM;
> else if (!strcmp(value, "current"))
> push_default = PUSH_DEFAULT_CURRENT;
> - else {
> - error("malformed value for %s: %s", var, value);
> - return error("Must be one of nothing, matching, simple,
> "
> - "upstream or current.");
> - }
> + else
> + return error("malformed value for %s: %s\n"
> + "Must be one of nothing, matching, simple,
> "
> + "upstream or current.",
> + var, value);
The same comment as an earlier warning().
> - if (flags & CONNECT_VERBOSE)
> - fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host,
> port);
> + if (flags & CONNECT_VERBOSE) {
> + fprintf_ln(stderr, "done.");
> + fprintf(stderr, "Connecting to %s (port %s) ... ", host, port);
> + }
It was not immediately obvious why this is a good change, but with
this patch, we have many instances of "done." that can share the
same translation, I guess.
> diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
> diff --git a/t/t3005-ls-files-relative.sh b/t/t3005-ls-files-relative.sh
> diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
> diff --git a/t/t7063-status-untracked-cache.sh
> b/t/t7063-status-untracked-cache.sh
It is surprising that the fallout from the conversions in the rest
of the patch is this small ;-)
Whew. This was a rather sizeable patch. The parts I did not quote
and comment all looked good.
Thanks.