git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking
@ 2015-05-06 18:51 Alangi Derick
  2015-05-06 19:23 ` Junio C Hamano
  2015-05-06 19:26 ` Stefan Beller
  0 siblings, 2 replies; 5+ messages in thread
From: Alangi Derick @ 2015-05-06 18:51 UTC (permalink / raw)


Signed-off-by: Alangi Derick <alangiderick@gmail.com>
---
 config.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/config.c b/config.c
index 66c0a51..cc41dbb 100644
--- a/config.c
+++ b/config.c
@@ -76,7 +76,7 @@ static int config_buf_ungetc(int c, struct config_source *conf)
 	if (conf->u.buf.pos > 0) {
 		conf->u.buf.pos--;
 		if (conf->u.buf.buf[conf->u.buf.pos] != c)
-			die("BUG: config_buf can only ungetc the same character");
+			die(_("BUG: config_buf can only ungetc the same character"));
 		return c;
 	}
 
@@ -106,7 +106,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
 
 	expanded = expand_user_path(path);
 	if (!expanded)
-		return error("Could not expand include path '%s'", path);
+		return error(_("Could not expand include path '%s'"), path);
 	path = expanded;
 
 	/*
@@ -117,7 +117,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
 		char *slash;
 
 		if (!cf || !cf->path)
-			return error("relative config includes must come from files");
+			return error(_("relative config includes must come from files"));
 
 		slash = find_last_dir_sep(cf->path);
 		if (slash)
@@ -177,7 +177,7 @@ int git_config_parse_parameter(const char *text,
 
 	pair = strbuf_split_str(text, '=', 2);
 	if (!pair[0])
-		return error("bogus config parameter: %s", text);
+		return error(_("bogus config parameter: %s"), text);
 
 	if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
 		strbuf_setlen(pair[0], pair[0]->len - 1);
@@ -189,7 +189,7 @@ int git_config_parse_parameter(const char *text,
 	strbuf_trim(pair[0]);
 	if (!pair[0]->len) {
 		strbuf_list_free(pair);
-		return error("bogus config parameter: %s", text);
+		return error(_("bogus config parameter: %s"), text);
 	}
 	strbuf_tolower(pair[0]);
 	if (fn(pair[0]->buf, value, data) < 0) {
@@ -854,7 +854,7 @@ static int git_default_core_config(const char *var, const char *value)
 			comment_line_char = value[0];
 			auto_comment_line_char = 0;
 		} else
-			return error("core.commentChar should only be one character");
+			return error(_("core.commentChar should only be one character"));
 		return 0;
 	}
 
@@ -949,7 +949,7 @@ static int git_default_branch_config(const char *var, const char *value)
 		else if (!strcmp(value, "always"))
 			autorebase = AUTOREBASE_ALWAYS;
 		else
-			return error("Malformed value for %s", var);
+			return error(_("Malformed value for %s"), var);
 		return 0;
 	}
 
@@ -976,8 +976,8 @@ static int git_default_push_config(const char *var, const char *value)
 			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.");
+			return error(_("Must be one of nothing, matching, simple, "
+				     "upstream or current."));
 		}
 		return 0;
 	}
@@ -1124,10 +1124,10 @@ static int git_config_from_blob_sha1(config_fn_t fn,
 
 	buf = read_sha1_file(sha1, &type, &size);
 	if (!buf)
-		return error("unable to load config blob object '%s'", name);
+		return error(_("unable to load config blob object '%s'"), name);
 	if (type != OBJ_BLOB) {
 		free(buf);
-		return error("reference '%s' does not point to a blob", name);
+		return error(_("reference '%s' does not point to a blob"), name);
 	}
 
 	ret = git_config_from_buf(fn, name, buf, size, data);
@@ -1143,7 +1143,7 @@ static int git_config_from_blob_ref(config_fn_t fn,
 	unsigned char sha1[20];
 
 	if (get_sha1(name, sha1) < 0)
-		return error("unable to resolve config blob '%s'", name);
+		return error(_("unable to resolve config blob '%s'"), name);
 	return git_config_from_blob_sha1(fn, name, sha1, data);
 }
 
@@ -1173,7 +1173,7 @@ unsigned long git_env_ulong(const char *k, unsigned long val)
 {
 	const char *v = getenv(k);
 	if (v && !git_parse_ulong(v, &val))
-		die("failed to parse %s", k);
+		die(_("failed to parse %s"), k);
 	return val;
 }
 
@@ -1720,7 +1720,7 @@ static int store_aux(const char *key, const char *value, void *cb)
 
 static int write_error(const char *filename)
 {
-	error("failed to write new configuration file %s", filename);
+	error(_("failed to write new configuration file %s"), filename);
 
 	/* Same error code as "failed to rename". */
 	return 4;
@@ -1859,12 +1859,12 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
 	 */
 
 	if (last_dot == NULL || last_dot == key) {
-		error("key does not contain a section: %s", key);
+		error(_("key does not contain a section: %s"), key);
 		return -CONFIG_NO_SECTION_OR_NAME;
 	}
 
 	if (!last_dot[1]) {
-		error("key does not contain variable name: %s", key);
+		error(_("key does not contain variable name: %s"), key);
 		return -CONFIG_NO_SECTION_OR_NAME;
 	}
 
@@ -1886,12 +1886,12 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
 		if (!dot || i > baselen) {
 			if (!iskeychar(c) ||
 			    (i == baselen + 1 && !isalpha(c))) {
-				error("invalid key: %s", key);
+				error(_("invalid key: %s"), key);
 				goto out_free_ret_1;
 			}
 			c = tolower(c);
 		} else if (c == '\n') {
-			error("invalid key (newline): %s", key);
+			error(_("invalid key (newline): %s"), key);
 			goto out_free_ret_1;
 		}
 		(*store_key)[i] = c;
@@ -2113,7 +2113,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
 	}
 
 	if (commit_lock_file(lock) < 0) {
-		error("could not commit config file %s", config_filename);
+		error(_("could not commit config file %s"), config_filename);
 		ret = CONFIG_NO_WRITE;
 		lock = NULL;
 		goto out_free;
@@ -2228,7 +2228,7 @@ int git_config_rename_section_in_file(const char *config_filename,
 	lock = xcalloc(1, sizeof(struct lock_file));
 	out_fd = hold_lock_file_for_update(lock, config_filename, 0);
 	if (out_fd < 0) {
-		ret = error("could not lock config file %s", config_filename);
+		ret = error(_("could not lock config file %s"), config_filename);
 		goto out;
 	}
 
@@ -2240,7 +2240,7 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fstat(fileno(config_file), &st);
 
 	if (chmod(lock->filename.buf, st.st_mode & 07777) < 0) {
-		ret = error("chmod on %s failed: %s",
+		ret = error(_("chmod on %s failed: %s"),
 				lock->filename.buf, strerror(errno));
 		goto out;
 	}
@@ -2295,7 +2295,7 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fclose(config_file);
 unlock_and_out:
 	if (commit_lock_file(lock) < 0)
-		ret = error("could not commit config file %s", config_filename);
+		ret = error(_("could not commit config file %s"), config_filename);
 out:
 	free(filename_buf);
 	return ret;
@@ -2313,7 +2313,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
 #undef config_error_nonbool
 int config_error_nonbool(const char *var)
 {
-	return error("Missing value for '%s'", var);
+	return error(_("Missing value for '%s'"), var);
 }
 
 int parse_config_key(const char *var,
-- 
2.4.0.dirty

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking
  2015-05-06 18:51 [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking Alangi Derick
@ 2015-05-06 19:23 ` Junio C Hamano
  2015-05-06 19:26 ` Stefan Beller
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2015-05-06 19:23 UTC (permalink / raw)
  To: Alangi Derick; +Cc: git

Alangi Derick <alangiderick@gmail.com> writes:

>> Cc: unlisted-recipients:; (no To-header on input)

The comments in $gmane/268330 still applies to this one.

    It seems you are posting putting the list in Bcc. Don't do that:
    it makes it painful to reply to your message (I had to re-add
    git@vger manually).


>> Subject: Re: [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking

The first paragraph of your commit message becomes the patch title
and conveyed on the "Subject:" line.  So

 (1) Keep the first paragraph to one single line.
 (2) Keep the length of that line short and to the point.

Also the comments in $gmane/268335 still applies to this one.

SubmittingPatches prefers to see an "<area>:" prefix so
that output of "git shortlog --no-merges -100" would give the
readers a better overview of the changes.

When "fix a translation error in config file..." appears among 100
other commits in "git shortlog" output, what kind of change would a
reader imagine this to be, though?

My answer to that question would be: "There was an existing
translation in 'git config' output, that was incorrect in some
unspecified way, and this change corrects that breakage."

And that is not what is going on, so the change is mistitled.

Perhaps

    config.c: mark error strings for translation

or something, modelling after 8262aaa2 (config.c: mark error and
warnings strings for translation, 2014-08-07), may be more
appropriate.  Personally, I do not think the log message for this
change needs anything more than that title.

> Signed-off-by: Alangi Derick <alangiderick@gmail.com>
> ---
>  config.c | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/config.c b/config.c
> index 66c0a51..cc41dbb 100644
> --- a/config.c
> +++ b/config.c
> @@ -76,7 +76,7 @@ static int config_buf_ungetc(int c, struct config_source *conf)
>  	if (conf->u.buf.pos > 0) {
>  		conf->u.buf.pos--;
>  		if (conf->u.buf.buf[conf->u.buf.pos] != c)
> -			die("BUG: config_buf can only ungetc the same character");
> +			die(_("BUG: config_buf can only ungetc the same character"));

I do not think this change is a good idea.

Comments in $gmane/268373 still applies to this version.

"BUG:" is a sign that we encountered an unexpected condition, and
untranslated message is much easier for Git developers to spot where
it came from.

> @@ -976,8 +976,8 @@ static int git_default_push_config(const char *var, const char *value)
>  			push_default = PUSH_DEFAULT_CURRENT;
>  		else {
>  			error("Malformed value for %s: %s", var, value);

Why not this one?

> -			return error("Must be one of nothing, matching, simple, "
> -				     "upstream or current.");
> +			return error(_("Must be one of nothing, matching, simple, "
> +				     "upstream or current."));
>  		}
>  		return 0;
>  	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking
  2015-05-06 18:51 [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking Alangi Derick
  2015-05-06 19:23 ` Junio C Hamano
@ 2015-05-06 19:26 ` Stefan Beller
  2015-05-06 19:33   ` Alangi Derick
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Beller @ 2015-05-06 19:26 UTC (permalink / raw)
  To: Alangi Derick, git

Please don't BCC all recipients, but just CC or send it to them.


On Wed, May 6, 2015 at 11:51 AM, Alangi Derick <alangiderick@gmail.com> wrote:

Usually here comes a rationale why the changes below are worth accepting
such as:

    This enables translations in git-config, which is a porcelain user facing
    command, so we want to show localized error messages.

Mind that there are 2 different files ./config.c and ./builtin/config.c
While ./builtin/config.c is used for the "git config" command and would
benefit from the error translation, I am unsure about ./config.c

All files directly in the top level directory from Git are usually quite
library like and used by the different commands in the builtin/ directory.
So I suspect there is a plumbing command which would make use of
these code paths, which is what we want to avoid.

> Signed-off-by: Alangi Derick <alangiderick@gmail.com>
> ---
>  config.c | 46 +++++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/config.c b/config.c
> index 66c0a51..cc41dbb 100644
> --- a/config.c
> +++ b/config.c
> @@ -76,7 +76,7 @@ static int config_buf_ungetc(int c, struct config_source *conf)
>         if (conf->u.buf.pos > 0) {
>                 conf->u.buf.pos--;
>                 if (conf->u.buf.buf[conf->u.buf.pos] != c)
> -                       die("BUG: config_buf can only ungetc the same character");
> +                       die(_("BUG: config_buf can only ungetc the same character"));
>                 return c;
>         }
>
> @@ -106,7 +106,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
>
>         expanded = expand_user_path(path);
>         if (!expanded)
> -               return error("Could not expand include path '%s'", path);
> +               return error(_("Could not expand include path '%s'"), path);
>         path = expanded;
>
>         /*
> @@ -117,7 +117,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
>                 char *slash;
>
>                 if (!cf || !cf->path)
> -                       return error("relative config includes must come from files");
> +                       return error(_("relative config includes must come from files"));
>
>                 slash = find_last_dir_sep(cf->path);
>                 if (slash)
> @@ -177,7 +177,7 @@ int git_config_parse_parameter(const char *text,
>
>         pair = strbuf_split_str(text, '=', 2);
>         if (!pair[0])
> -               return error("bogus config parameter: %s", text);
> +               return error(_("bogus config parameter: %s"), text);
>
>         if (pair[0]->len && pair[0]->buf[pair[0]->len - 1] == '=') {
>                 strbuf_setlen(pair[0], pair[0]->len - 1);
> @@ -189,7 +189,7 @@ int git_config_parse_parameter(const char *text,
>         strbuf_trim(pair[0]);
>         if (!pair[0]->len) {
>                 strbuf_list_free(pair);
> -               return error("bogus config parameter: %s", text);
> +               return error(_("bogus config parameter: %s"), text);
>         }
>         strbuf_tolower(pair[0]);
>         if (fn(pair[0]->buf, value, data) < 0) {
> @@ -854,7 +854,7 @@ static int git_default_core_config(const char *var, const char *value)
>                         comment_line_char = value[0];
>                         auto_comment_line_char = 0;
>                 } else
> -                       return error("core.commentChar should only be one character");
> +                       return error(_("core.commentChar should only be one character"));
>                 return 0;
>         }
>
> @@ -949,7 +949,7 @@ static int git_default_branch_config(const char *var, const char *value)
>                 else if (!strcmp(value, "always"))
>                         autorebase = AUTOREBASE_ALWAYS;
>                 else
> -                       return error("Malformed value for %s", var);
> +                       return error(_("Malformed value for %s"), var);
>                 return 0;
>         }
>
> @@ -976,8 +976,8 @@ static int git_default_push_config(const char *var, const char *value)
>                         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.");
> +                       return error(_("Must be one of nothing, matching, simple, "
> +                                    "upstream or current."));
>                 }
>                 return 0;
>         }
> @@ -1124,10 +1124,10 @@ static int git_config_from_blob_sha1(config_fn_t fn,
>
>         buf = read_sha1_file(sha1, &type, &size);
>         if (!buf)
> -               return error("unable to load config blob object '%s'", name);
> +               return error(_("unable to load config blob object '%s'"), name);
>         if (type != OBJ_BLOB) {
>                 free(buf);
> -               return error("reference '%s' does not point to a blob", name);
> +               return error(_("reference '%s' does not point to a blob"), name);
>         }
>
>         ret = git_config_from_buf(fn, name, buf, size, data);
> @@ -1143,7 +1143,7 @@ static int git_config_from_blob_ref(config_fn_t fn,
>         unsigned char sha1[20];
>
>         if (get_sha1(name, sha1) < 0)
> -               return error("unable to resolve config blob '%s'", name);
> +               return error(_("unable to resolve config blob '%s'"), name);
>         return git_config_from_blob_sha1(fn, name, sha1, data);
>  }
>
> @@ -1173,7 +1173,7 @@ unsigned long git_env_ulong(const char *k, unsigned long val)
>  {
>         const char *v = getenv(k);
>         if (v && !git_parse_ulong(v, &val))
> -               die("failed to parse %s", k);
> +               die(_("failed to parse %s"), k);
>         return val;
>  }
>
> @@ -1720,7 +1720,7 @@ static int store_aux(const char *key, const char *value, void *cb)
>
>  static int write_error(const char *filename)
>  {
> -       error("failed to write new configuration file %s", filename);
> +       error(_("failed to write new configuration file %s"), filename);
>
>         /* Same error code as "failed to rename". */
>         return 4;
> @@ -1859,12 +1859,12 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
>          */
>
>         if (last_dot == NULL || last_dot == key) {
> -               error("key does not contain a section: %s", key);
> +               error(_("key does not contain a section: %s"), key);
>                 return -CONFIG_NO_SECTION_OR_NAME;
>         }
>
>         if (!last_dot[1]) {
> -               error("key does not contain variable name: %s", key);
> +               error(_("key does not contain variable name: %s"), key);
>                 return -CONFIG_NO_SECTION_OR_NAME;
>         }
>
> @@ -1886,12 +1886,12 @@ int git_config_parse_key(const char *key, char **store_key, int *baselen_)
>                 if (!dot || i > baselen) {
>                         if (!iskeychar(c) ||
>                             (i == baselen + 1 && !isalpha(c))) {
> -                               error("invalid key: %s", key);
> +                               error(_("invalid key: %s"), key);
>                                 goto out_free_ret_1;
>                         }
>                         c = tolower(c);
>                 } else if (c == '\n') {
> -                       error("invalid key (newline): %s", key);
> +                       error(_("invalid key (newline): %s"), key);
>                         goto out_free_ret_1;
>                 }
>                 (*store_key)[i] = c;
> @@ -2113,7 +2113,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
>         }
>
>         if (commit_lock_file(lock) < 0) {
> -               error("could not commit config file %s", config_filename);
> +               error(_("could not commit config file %s"), config_filename);
>                 ret = CONFIG_NO_WRITE;
>                 lock = NULL;
>                 goto out_free;
> @@ -2228,7 +2228,7 @@ int git_config_rename_section_in_file(const char *config_filename,
>         lock = xcalloc(1, sizeof(struct lock_file));
>         out_fd = hold_lock_file_for_update(lock, config_filename, 0);
>         if (out_fd < 0) {
> -               ret = error("could not lock config file %s", config_filename);
> +               ret = error(_("could not lock config file %s"), config_filename);
>                 goto out;
>         }
>
> @@ -2240,7 +2240,7 @@ int git_config_rename_section_in_file(const char *config_filename,
>         fstat(fileno(config_file), &st);
>
>         if (chmod(lock->filename.buf, st.st_mode & 07777) < 0) {
> -               ret = error("chmod on %s failed: %s",
> +               ret = error(_("chmod on %s failed: %s"),
>                                 lock->filename.buf, strerror(errno));
>                 goto out;
>         }
> @@ -2295,7 +2295,7 @@ int git_config_rename_section_in_file(const char *config_filename,
>         fclose(config_file);
>  unlock_and_out:
>         if (commit_lock_file(lock) < 0)
> -               ret = error("could not commit config file %s", config_filename);
> +               ret = error(_("could not commit config file %s"), config_filename);
>  out:
>         free(filename_buf);
>         return ret;
> @@ -2313,7 +2313,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
>  #undef config_error_nonbool
>  int config_error_nonbool(const char *var)
>  {
> -       return error("Missing value for '%s'", var);
> +       return error(_("Missing value for '%s'"), var);
>  }
>
>  int parse_config_key(const char *var,
> --
> 2.4.0.dirty
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking
  2015-05-06 19:26 ` Stefan Beller
@ 2015-05-06 19:33   ` Alangi Derick
  2015-05-06 19:47     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Alangi Derick @ 2015-05-06 19:33 UTC (permalink / raw)
  To: Stefan Beller; +Cc: git

Thanks so much for the correction. So the points i should not is that;
- I shouldn't Bcc but i should instead Cc
- I should work with porcelain commands and not plumbing commands
- My patch should have a description and a brief title
But my problem is figuring out the porcelain commands from the
plumbing commands. But that is a task for me to do. Let me fix the Bcc
problem.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking
  2015-05-06 19:33   ` Alangi Derick
@ 2015-05-06 19:47     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2015-05-06 19:47 UTC (permalink / raw)
  To: Alangi Derick; +Cc: Stefan Beller, git

Alangi Derick <alangiderick@gmail.com> writes:

> Thanks so much for the correction. So the points i should not is that;
> - I shouldn't Bcc but i should instead Cc

You are sending to a single recipient, git@vger.kernel.org; To:
should be the most natural thing to do, not Cc:.

> But my problem is figuring out the porcelain commands from the
> plumbing commands.

"git help git" should list the commands in categories.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-06 19:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 18:51 [PATCH] fixed translation in config file to enhance user output message from the porcelain command(git config). This fixes the error and die function by wrapping it in the _(...) function. This also avoid the code from breaking Alangi Derick
2015-05-06 19:23 ` Junio C Hamano
2015-05-06 19:26 ` Stefan Beller
2015-05-06 19:33   ` Alangi Derick
2015-05-06 19:47     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).