git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/12] Mark more strings for translation
@ 2018-10-28  6:51 Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 01/12] git.c: mark " Nguyễn Thái Ngọc Duy
                   ` (12 more replies)
  0 siblings, 13 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Not much to write here. I make a note whenever I see unstranslated
strings during review and this is the result. There are some more code
changes than just adding _() though, e.g. 10/12.

Nguyễn Thái Ngọc Duy (12):
  git.c: mark more strings for translation
  alias.c: mark split_cmdline_strerror() strings for translation
  archive.c: mark more strings for translation
  attr.c: mark more string for translation
  read-cache.c: mark more strings for translation
  read-cache.c: add missing colon separators
  reflog: mark strings for translation
  remote.c: mark messages for translation
  repack: mark more strings for translation
  parse-options: replace opterror() with optname()
  parse-options.c: mark more strings for translation
  fsck: mark strings for translation

 alias.c                    |   4 +-
 archive.c                  |   8 +--
 attr.c                     |   2 +-
 builtin/fsck.c             | 113 ++++++++++++++++++++-----------------
 builtin/merge.c            |   4 +-
 builtin/reflog.c           |  34 ++++++-----
 builtin/repack.c           |  26 ++++-----
 builtin/revert.c           |   3 +-
 git.c                      |  32 +++++------
 parse-options-cb.c         |   7 ++-
 parse-options.c            |  64 +++++++++++----------
 parse-options.h            |   5 +-
 read-cache.c               |  73 ++++++++++++------------
 ref-filter.c               |   8 ++-
 remote.c                   |  49 ++++++++--------
 t/t0040-parse-options.sh   |   4 +-
 t/t1410-reflog.sh          |   6 +-
 t/t1450-fsck.sh            |  52 ++++++++---------
 t/t4211-line-log.sh        |   2 +-
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +-
 21 files changed, 264 insertions(+), 242 deletions(-)

-- 
2.19.1.647.g708186aaf9


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

* [PATCH 01/12] git.c: mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 02/12] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/git.c b/git.c
index adac132956..1ad565c5c8 100644
--- a/git.c
+++ b/git.c
@@ -338,27 +338,27 @@ static int handle_alias(int *argcp, const char ***argv)
 			if (ret >= 0)   /* normal exit */
 				exit(ret);
 
-			die_errno("while expanding alias '%s': '%s'",
-			    alias_command, alias_string + 1);
+			die_errno(_("while expanding alias '%s': '%s'"),
+				  alias_command, alias_string + 1);
 		}
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
-			die("Bad alias.%s string: %s", alias_command,
+			die(_("bad alias.%s string: %s"), alias_command,
 			    split_cmdline_strerror(count));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
-			die("alias '%s' changes environment variables.\n"
-				 "You can use '!git' in the alias to do this",
-				 alias_command);
+			die(_("alias '%s' changes environment variables.\n"
+			      "You can use '!git' in the alias to do this"),
+			    alias_command);
 		memmove(new_argv - option_count, new_argv,
 				count * sizeof(char *));
 		new_argv -= option_count;
 
 		if (count < 1)
-			die("empty alias for %s", alias_command);
+			die(_("empty alias for %s"), alias_command);
 
 		if (!strcmp(alias_command, new_argv[0]))
-			die("recursive alias: %s", alias_command);
+			die(_("recursive alias: %s"), alias_command);
 
 		trace_argv_printf(new_argv,
 				  "trace: alias expansion: %s =>",
@@ -409,7 +409,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	if (!help && get_super_prefix()) {
 		if (!(p->option & SUPPORT_SUPER_PREFIX))
-			die("%s doesn't support --super-prefix", p->cmd);
+			BUG("%s doesn't support --super-prefix", p->cmd);
 	}
 
 	if (!help && p->option & NEED_WORK_TREE)
@@ -433,11 +433,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	/* Check for ENOSPC and EIO errors.. */
 	if (fflush(stdout))
-		die_errno("write failure on standard output");
+		die_errno(_("write failure on standard output"));
 	if (ferror(stdout))
-		die("unknown write failure on standard output");
+		die(_("unknown write failure on standard output"));
 	if (fclose(stdout))
-		die_errno("close failed on standard output");
+		die_errno(_("close failed on standard output"));
 	return 0;
 }
 
@@ -648,7 +648,7 @@ static void execv_dashed_external(const char **argv)
 	int status;
 
 	if (get_super_prefix())
-		die("%s doesn't support --super-prefix", argv[0]);
+		BUG("%s doesn't support --super-prefix", argv[0]);
 
 	if (use_pager == -1 && !is_builtin(argv[0]))
 		use_pager = check_pager_config(argv[0]);
@@ -760,7 +760,7 @@ int cmd_main(int argc, const char **argv)
 	if (skip_prefix(cmd, "git-", &cmd)) {
 		argv[0] = cmd;
 		handle_builtin(argc, argv);
-		die("cannot handle %s as a builtin", cmd);
+		die(_("cannot handle %s as a builtin"), cmd);
 	}
 
 	/* Look for flags.. */
@@ -773,7 +773,7 @@ int cmd_main(int argc, const char **argv)
 	} else {
 		/* The user didn't specify a command; give them help */
 		commit_pager_choice();
-		printf("usage: %s\n\n", git_usage_string);
+		printf(_("usage: %s\n\n"), git_usage_string);
 		list_common_cmds_help();
 		printf("\n%s\n", _(git_more_info_string));
 		exit(1);
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 02/12] alias.c: mark split_cmdline_strerror() strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 01/12] git.c: mark " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 03/12] archive.c: mark more " Nguyễn Thái Ngọc Duy
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

This function can be part of translated messages. To make sure we
don't have a sentence with mixed languages, mark the strings for
translation, but only use translated strings in places we know we will
output translated strings.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 alias.c         | 4 ++--
 builtin/merge.c | 2 +-
 git.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/alias.c b/alias.c
index a7e4e57130..c471538020 100644
--- a/alias.c
+++ b/alias.c
@@ -47,8 +47,8 @@ void list_aliases(struct string_list *list)
 #define SPLIT_CMDLINE_BAD_ENDING 1
 #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
 static const char *split_cmdline_errors[] = {
-	"cmdline ends with \\",
-	"unclosed quote"
+	N_("cmdline ends with \\"),
+	N_("unclosed quote")
 };
 
 int split_cmdline(char *cmdline, const char ***argv)
diff --git a/builtin/merge.c b/builtin/merge.c
index 4aa6071598..92ba7e1c6d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -577,7 +577,7 @@ static void parse_branch_merge_options(char *bmo)
 	argc = split_cmdline(bmo, &argv);
 	if (argc < 0)
 		die(_("Bad branch.%s.mergeoptions string: %s"), branch,
-		    split_cmdline_strerror(argc));
+		    _(split_cmdline_strerror(argc)));
 	REALLOC_ARRAY(argv, argc + 2);
 	MOVE_ARRAY(argv + 1, argv, argc + 1);
 	argc++;
diff --git a/git.c b/git.c
index 1ad565c5c8..09d6169f6c 100644
--- a/git.c
+++ b/git.c
@@ -344,7 +344,7 @@ static int handle_alias(int *argcp, const char ***argv)
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
 			die(_("bad alias.%s string: %s"), alias_command,
-			    split_cmdline_strerror(count));
+			    _(split_cmdline_strerror(count)));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
 			die(_("alias '%s' changes environment variables.\n"
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 03/12] archive.c: mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 01/12] git.c: mark " Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 02/12] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 04/12] attr.c: mark more string " Nguyễn Thái Ngọc Duy
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 archive.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/archive.c b/archive.c
index 9d16b7fadf..757519a9d6 100644
--- a/archive.c
+++ b/archive.c
@@ -385,12 +385,12 @@ static void parse_treeish_arg(const char **argv,
 		int refnamelen = colon - name;
 
 		if (!dwim_ref(name, refnamelen, &oid, &ref))
-			die("no such ref: %.*s", refnamelen, name);
+			die(_("no such ref: %.*s"), refnamelen, name);
 		free(ref);
 	}
 
 	if (get_oid(name, &oid))
-		die("Not a valid object name");
+		die(_("'%s' is not a valid object name"), name);
 
 	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
 	if (commit) {
@@ -403,7 +403,7 @@ static void parse_treeish_arg(const char **argv,
 
 	tree = parse_tree_indirect(&oid);
 	if (tree == NULL)
-		die("not a tree object");
+		die(_("%s is not a tree object"), oid_to_hex(&oid));
 
 	if (prefix) {
 		struct object_id tree_oid;
@@ -413,7 +413,7 @@ static void parse_treeish_arg(const char **argv,
 		err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
 				     &mode);
 		if (err || !S_ISDIR(mode))
-			die("current working directory is untracked");
+			die(_("current working directory is untracked"));
 
 		tree = parse_tree_indirect(&tree_oid);
 	}
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 04/12] attr.c: mark more string for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 03/12] archive.c: mark more " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 05/12] read-cache.c: mark more strings " Nguyễn Thái Ngọc Duy
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/attr.c b/attr.c
index 60d284796d..4ebc169abe 100644
--- a/attr.c
+++ b/attr.c
@@ -372,7 +372,7 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
 	if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
 	    starts_with(name, ATTRIBUTE_MACRO_PREFIX)) {
 		if (!macro_ok) {
-			fprintf(stderr, "%s not allowed: %s:%d\n",
+			fprintf(stderr, _("%s not allowed: %s:%d\n"),
 				name, src, lineno);
 			goto fail_return;
 		}
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 05/12] read-cache.c: mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 04/12] attr.c: mark more string " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 06/12] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

There are a couple other improvements on these strings as well:

 - add missing colon (as separator)
 - quote paths
 - provide more information on error messages
 - keep first word in lowercase
 - some die() become BUG()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c    | 63 +++++++++++++++++++++++++------------------------
 t/t1450-fsck.sh |  2 +-
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index d57958233e..5083cd8333 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -316,7 +316,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
 			changed |= DATA_CHANGED;
 		return changed;
 	default:
-		die("internal error: ce_mode is %o", ce->ce_mode);
+		BUG("unsupported ce_mode %o", ce->ce_mode);
 	}
 
 	changed |= match_stat_data(&ce->ce_stat_data, st);
@@ -672,7 +672,8 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
 	struct cache_entry *new_entry;
 
 	if (alias->ce_flags & CE_ADDED)
-		die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+		die(_("will not add file alias '%s' ('%s' already exists in index)"),
+		    ce->name, alias->name);
 
 	/* Ok, create the new entry using the name of the existing alias */
 	len = ce_namelen(alias);
@@ -687,7 +688,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
 {
 	struct object_id oid;
 	if (write_object_file("", 0, blob_type, &oid))
-		die("cannot create an empty blob in the object database");
+		die(_("cannot create an empty blob in the object database"));
 	oidcpy(&ce->oid, &oid);
 }
 
@@ -708,7 +709,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		newflags |= HASH_RENORMALIZE;
 
 	if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
-		return error("%s: can only add regular files, symbolic links or git-directories", path);
+		return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
 
 	namelen = strlen(path);
 	if (S_ISDIR(st_mode)) {
@@ -763,7 +764,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 	if (!intent_only) {
 		if (index_path(istate, &ce->oid, path, st, newflags)) {
 			discard_cache_entry(ce);
-			return error("unable to index file %s", path);
+			return error(_("unable to index file '%s'"), path);
 		}
 	} else
 		set_object_name_for_intent_to_add_entry(ce);
@@ -782,7 +783,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		discard_cache_entry(ce);
 	else if (add_index_entry(istate, ce, add_option)) {
 		discard_cache_entry(ce);
-		return error("unable to add %s to index", path);
+		return error(_("unable to add '%s' to index"), path);
 	}
 	if (verbose && !was_same)
 		printf("add '%s'\n", path);
@@ -793,7 +794,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
 {
 	struct stat st;
 	if (lstat(path, &st))
-		die_errno("unable to stat '%s'", path);
+		die_errno(_("unable to stat '%s'"), path);
 	return add_to_index(istate, path, &st, flags);
 }
 
@@ -818,7 +819,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -844,7 +845,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -1297,12 +1298,12 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
 	if (!ok_to_add)
 		return -1;
 	if (!verify_path(ce->name, ce->ce_mode))
-		return error("Invalid path '%s'", ce->name);
+		return error(_("invalid path '%s'"), ce->name);
 
 	if (!skip_df_check &&
 	    check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
 		if (!ok_to_replace)
-			return error("'%s' appears as both a file and as a directory",
+			return error(_("'%s' appears as both a file and as a directory"),
 				     ce->name);
 		pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
 		pos = -pos-1;
@@ -1676,10 +1677,10 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	int hdr_version;
 
 	if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
-		return error("bad signature");
+		return error(_("bad signature 0x%08x"), hdr->hdr_signature);
 	hdr_version = ntohl(hdr->hdr_version);
 	if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
-		return error("bad index version %d", hdr_version);
+		return error(_("bad index version %d"), hdr_version);
 
 	if (!verify_index_checksum)
 		return 0;
@@ -1688,7 +1689,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
 	the_hash_algo->final_fn(hash, &c);
 	if (!hasheq(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
-		return error("bad index file sha1 signature");
+		return error(_("bad index file sha1 signature"));
 	return 0;
 }
 
@@ -1718,9 +1719,9 @@ static int read_index_extension(struct index_state *istate,
 		break;
 	default:
 		if (*ext < 'A' || 'Z' < *ext)
-			return error("index uses %.4s extension, which we do not understand",
+			return error(_("index uses %.4s extension, which we do not understand"),
 				     ext);
-		fprintf(stderr, "ignoring %.4s extension\n", ext);
+		fprintf_ln(stderr, _("ignoring %.4s extension"), ext);
 		break;
 	}
 	return 0;
@@ -1767,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
 		extended_flags = get_be16(&ondisk2->flags2) << 16;
 		/* We do not yet understand any bit out of CE_EXTENDED_FLAGS */
 		if (extended_flags & ~CE_EXTENDED_FLAGS)
-			die("Unknown index entry format %08x", extended_flags);
+			die(_("unknown index entry format 0x%08x"), extended_flags);
 		flags |= extended_flags;
 		name = ondisk2->name;
 	}
@@ -1840,13 +1841,13 @@ static void check_ce_order(struct index_state *istate)
 		int name_compare = strcmp(ce->name, next_ce->name);
 
 		if (0 < name_compare)
-			die("unordered stage entries in index");
+			die(_("unordered stage entries in index"));
 		if (!name_compare) {
 			if (!ce_stage(ce))
-				die("multiple stage entries for merged file '%s'",
+				die(_("multiple stage entries for merged file '%s'"),
 				    ce->name);
 			if (ce_stage(ce) > ce_stage(next_ce))
-				die("unordered stage entries for '%s'",
+				die(_("unordered stage entries for '%s'"),
 				    ce->name);
 		}
 	}
@@ -2149,19 +2150,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 	if (fd < 0) {
 		if (!must_exist && errno == ENOENT)
 			return 0;
-		die_errno("%s: index file open failed", path);
+		die_errno(_("%s: index file open failed"), path);
 	}
 
 	if (fstat(fd, &st))
-		die_errno("cannot stat the open index");
+		die_errno(_("%s: cannot stat the open index"), path);
 
 	mmap_size = xsize_t(st.st_size);
 	if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz)
-		die("index file smaller than expected");
+		die(_("%s: index file smaller than expected"), path);
 
 	mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	if (mmap == MAP_FAILED)
-		die_errno("unable to map index file");
+		die_errno(_("%s: unable to map index file"), path);
 	close(fd);
 
 	hdr = (const struct cache_header *)mmap;
@@ -2243,7 +2244,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 
 unmap:
 	munmap((void *)mmap, mmap_size);
-	die("index file corrupt");
+	die(_("index file corrupt"));
 }
 
 /*
@@ -2255,7 +2256,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 static void freshen_shared_index(const char *shared_index, int warn)
 {
 	if (!check_and_freshen_file(shared_index, 1) && warn)
-		warning("could not freshen shared index '%s'", shared_index);
+		warning(_("could not freshen shared index '%s'"), shared_index);
 }
 
 int read_index_from(struct index_state *istate, const char *path,
@@ -2290,7 +2291,7 @@ int read_index_from(struct index_state *istate, const char *path,
 	base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
 	ret = do_read_index(split_index->base, base_path, 1);
 	if (!oideq(&split_index->base_oid, &split_index->base->oid))
-		die("broken index, expect %s in %s, got %s",
+		die(_("broken index, expect %s in %s, got %s"),
 		    base_oid_hex, base_path,
 		    oid_to_hex(&split_index->base->oid));
 
@@ -2356,14 +2357,14 @@ void validate_cache_entries(const struct index_state *istate)
 
 	for (i = 0; i < istate->cache_nr; i++) {
 		if (!istate) {
-			die("internal error: cache entry is not allocated from expected memory pool");
+			BUG("cache entry is not allocated from expected memory pool");
 		} else if (!istate->ce_mem_pool ||
 			!mem_pool_contains(istate->ce_mem_pool, istate->cache[i])) {
 			if (!istate->split_index ||
 				!istate->split_index->base ||
 				!istate->split_index->base->ce_mem_pool ||
 				!mem_pool_contains(istate->split_index->base->ce_mem_pool, istate->cache[i])) {
-				die("internal error: cache entry is not allocated from expected memory pool");
+				BUG("cache entry is not allocated from expected memory pool");
 			}
 		}
 	}
@@ -3076,7 +3077,7 @@ static int write_shared_index(struct index_state *istate,
 		return ret;
 	ret = adjust_shared_perm(get_tempfile_path(*temp));
 	if (ret) {
-		error("cannot fix permission bits on %s", get_tempfile_path(*temp));
+		error(_("cannot fix permission bits on '%s'"), get_tempfile_path(*temp));
 		return ret;
 	}
 	ret = rename_tempfile(temp,
@@ -3222,7 +3223,7 @@ int read_index_unmerged(struct index_state *istate)
 		new_ce->ce_namelen = len;
 		new_ce->ce_mode = ce->ce_mode;
 		if (add_index_entry(istate, new_ce, ADD_CACHE_SKIP_DFCHECK))
-			return error("%s: cannot drop to stage #0",
+			return error(_("%s: cannot drop to stage #0"),
 				     new_ce->name);
 	}
 	return unmerged;
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 0f2dd26f74..90c765df3a 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -754,7 +754,7 @@ test_expect_success 'detect corrupt index file in fsck' '
 	test_when_finished "mv .git/index.backup .git/index" &&
 	corrupt_index_checksum &&
 	test_must_fail git fsck --cache 2>errors &&
-	grep "bad index file" errors
+	test_i18ngrep "bad index file" errors
 '
 
 test_done
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 06/12] read-cache.c: add missing colon separators
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 05/12] read-cache.c: mark more strings " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 07/12] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

typechange_fmt and added_fmt should have a colon before "needs
update". Align the statements to make it easier to read and see. Also
drop the unnecessary ().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 5083cd8333..02a49e957d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1492,11 +1492,11 @@ int refresh_index(struct index_state *istate, unsigned int flags,
 						  istate->cache_nr);
 
 	trace_performance_enter();
-	modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
-	deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
-	typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
-	added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
-	unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+	modified_fmt   = in_porcelain ? "M\t%s\n" : "%s: needs update\n";
+	deleted_fmt    = in_porcelain ? "D\t%s\n" : "%s: needs update\n";
+	typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n";
+	added_fmt      = in_porcelain ? "A\t%s\n" : "%s: needs update\n";
+	unmerged_fmt   = in_porcelain ? "U\t%s\n" : "%s: needs merge\n";
 	for (i = 0; i < istate->cache_nr; i++) {
 		struct cache_entry *ce, *new_entry;
 		int cache_errno = 0;
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 07/12] reflog: mark strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 06/12] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 08/12] remote.c: mark messages " Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/reflog.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index b5941c1ff3..33cb20b7d8 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -13,11 +13,15 @@
 
 /* NEEDSWORK: switch to using parse_options */
 static const char reflog_expire_usage[] =
-"git reflog expire [--expire=<time>] [--expire-unreachable=<time>] [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] <refs>...";
+	N_("git reflog expire [--expire=<time>] "
+	   "[--expire-unreachable=<time>] "
+	   "[--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] "
+	   "[--verbose] [--all] <refs>...");
 static const char reflog_delete_usage[] =
-"git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] <refs>...";
+	N_("git reflog delete [--rewrite] [--updateref] "
+	   "[--dry-run | -n] [--verbose] <refs>...");
 static const char reflog_exists_usage[] =
-"git reflog exists <ref>";
+	N_("git reflog exists <ref>");
 
 static timestamp_t default_reflog_expire;
 static timestamp_t default_reflog_expire_unreachable;
@@ -556,7 +560,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_expire_usage);
+			usage(_(reflog_expire_usage));
 		else
 			break;
 	}
@@ -569,7 +573,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 	if (cb.cmd.stalefix) {
 		repo_init_revisions(the_repository, &cb.cmd.revs, prefix);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
-			printf("Marking reachable objects...");
+			printf(_("Marking reachable objects..."));
 		mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
 			putchar('\n');
@@ -598,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 		char *ref;
 		struct object_id oid;
 		if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {
-			status |= error("%s points nowhere!", argv[i]);
+			status |= error(_("%s points nowhere!"), argv[i]);
 			continue;
 		}
 		set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
@@ -644,13 +648,13 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_delete_usage);
+			usage(_(reflog_delete_usage));
 		else
 			break;
 	}
 
 	if (argc - i < 1)
-		return error("Nothing to delete?");
+		return error(_("nothing to delete?"));
 
 	for ( ; i < argc; i++) {
 		const char *spec = strstr(argv[i], "@{");
@@ -659,12 +663,12 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 		int recno;
 
 		if (!spec) {
-			status |= error("Not a reflog: %s", argv[i]);
+			status |= error(_("not a reflog: %s"), argv[i]);
 			continue;
 		}
 
 		if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
-			status |= error("no reflog for '%s'", argv[i]);
+			status |= error(_("no reflog for '%s'"), argv[i]);
 			continue;
 		}
 
@@ -699,7 +703,7 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_exists_usage);
+			usage(_(reflog_exists_usage));
 		else
 			break;
 	}
@@ -707,10 +711,10 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 	start = i;
 
 	if (argc - start != 1)
-		usage(reflog_exists_usage);
+		usage(_(reflog_exists_usage));
 
 	if (check_refname_format(argv[start], REFNAME_ALLOW_ONELEVEL))
-		die("invalid ref format: %s", argv[start]);
+		die(_("invalid ref format: %s"), argv[start]);
 	return !reflog_exists(argv[start]);
 }
 
@@ -719,12 +723,12 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
  */
 
 static const char reflog_usage[] =
-"git reflog [ show | expire | delete | exists ]";
+	N_("git reflog [ show | expire | delete | exists ]");
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
 	if (argc > 1 && !strcmp(argv[1], "-h"))
-		usage(reflog_usage);
+		usage(_(reflog_usage));
 
 	/* With no command, we default to showing it. */
 	if (argc < 2 || *argv[1] == '-')
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 08/12] remote.c: mark messages for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 07/12] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-29  7:56   ` Junio C Hamano
  2018-10-28  6:51 ` [PATCH 09/12] repack: mark more strings " Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/remote.c b/remote.c
index 81f4f01b00..11b33d1625 100644
--- a/remote.c
+++ b/remote.c
@@ -359,7 +359,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		return 0;
 	/* Handle remote.<name>.* variables */
 	if (*name == '/') {
-		warning("Config remote shorthand cannot begin with '/': %s",
+		warning(_("config remote shorthand cannot begin with '/': %s"),
 			name);
 		return 0;
 	}
@@ -406,7 +406,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->receivepack)
 			remote->receivepack = v;
 		else
-			error("more than one receivepack given, using the first");
+			error(_("more than one receivepack given, using the first"));
 	} else if (!strcmp(subkey, "uploadpack")) {
 		const char *v;
 		if (git_config_string(&v, key, value))
@@ -414,7 +414,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->uploadpack)
 			remote->uploadpack = v;
 		else
-			error("more than one uploadpack given, using the first");
+			error(_("more than one uploadpack given, using the first"));
 	} else if (!strcmp(subkey, "tagopt")) {
 		if (!strcmp(value, "--no-tags"))
 			remote->fetch_tags = -1;
@@ -620,7 +620,7 @@ static void handle_duplicate(struct ref *ref1, struct ref *ref2)
 			 * FETCH_HEAD_IGNORE entries always appear at
 			 * the end of the list.
 			 */
-			die(_("Internal error"));
+			BUG("Internal error");
 		}
 	}
 	free(ref2->peer_ref);
@@ -680,7 +680,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 	size_t namelen;
 	int ret;
 	if (!kstar)
-		die("Key '%s' of pattern had no '*'", key);
+		die(_("key '%s' of pattern had no '*'"), key);
 	klen = kstar - key;
 	ksuffixlen = strlen(kstar + 1);
 	namelen = strlen(name);
@@ -690,7 +690,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 		struct strbuf sb = STRBUF_INIT;
 		const char *vstar = strchr(value, '*');
 		if (!vstar)
-			die("Value '%s' of pattern has no '*'", value);
+			die(_("value '%s' of pattern has no '*'"), value);
 		strbuf_add(&sb, value, vstar - value);
 		strbuf_add(&sb, name + klen, namelen - klen - ksuffixlen);
 		strbuf_addstr(&sb, vstar + 1);
@@ -707,7 +707,7 @@ static void query_refspecs_multiple(struct refspec *rs,
 	int find_src = !query->src;
 
 	if (find_src && !query->dst)
-		error("query_refspecs_multiple: need either src or dst");
+		BUG("query_refspecs_multiple: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
@@ -735,7 +735,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
 	char **result = find_src ? &query->src : &query->dst;
 
 	if (find_src && !query->dst)
-		return error("query_refspecs: need either src or dst");
+		BUG("query_refspecs: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
@@ -995,12 +995,12 @@ static int match_explicit_lhs(struct ref *src,
 		 * way to delete 'other' ref at the remote end.
 		 */
 		if (try_explicit_object_name(rs->src, match) < 0)
-			return error("src refspec %s does not match any.", rs->src);
+			return error(_("src refspec %s does not match any"), rs->src);
 		if (allocated_match)
 			*allocated_match = 1;
 		return 0;
 	default:
-		return error("src refspec %s matches more than one.", rs->src);
+		return error(_("src refspec %s matches more than one"), rs->src);
 	}
 }
 
@@ -1030,7 +1030,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (!dst_value ||
 		    ((flag & REF_ISSYMREF) &&
 		     !starts_with(dst_value, "refs/heads/")))
-			die("%s cannot be resolved to branch.",
+			die(_("%s cannot be resolved to branch"),
 			    matched_src->name);
 	}
 
@@ -1041,30 +1041,30 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (starts_with(dst_value, "refs/"))
 			matched_dst = make_linked_ref(dst_value, dst_tail);
 		else if (is_null_oid(&matched_src->new_oid))
-			error("unable to delete '%s': remote ref does not exist",
+			error(_("unable to delete '%s': remote ref does not exist"),
 			      dst_value);
 		else if ((dst_guess = guess_ref(dst_value, matched_src))) {
 			matched_dst = make_linked_ref(dst_guess, dst_tail);
 			free(dst_guess);
 		} else
-			error("unable to push to unqualified destination: %s\n"
-			      "The destination refspec neither matches an "
-			      "existing ref on the remote nor\n"
-			      "begins with refs/, and we are unable to "
-			      "guess a prefix based on the source ref.",
+			error(_("unable to push to unqualified destination: %s\n"
+				"The destination refspec neither matches an "
+				"existing ref on the remote nor\n"
+				"begins with refs/, and we are unable to "
+				"guess a prefix based on the source ref."),
 			      dst_value);
 		break;
 	default:
 		matched_dst = NULL;
-		error("dst refspec %s matches more than one.",
+		error(_("dst refspec %s matches more than one"),
 		      dst_value);
 		break;
 	}
 	if (!matched_dst)
 		return -1;
 	if (matched_dst->peer_ref)
-		return error("dst ref %s receives from more than one src.",
-		      matched_dst->name);
+		return error(_("dst ref %s receives from more than one src"),
+			     matched_dst->name);
 	else {
 		matched_dst->peer_ref = allocated_src ?
 					matched_src :
@@ -1750,7 +1750,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			ref_map = get_remote_ref(remote_refs, name);
 		}
 		if (!missing_ok && !ref_map)
-			die("Couldn't find remote ref %s", name);
+			die(_("couldn't find remote ref %s"), name);
 		if (ref_map) {
 			ref_map->peer_ref = get_local_ref(refspec->dst);
 			if (ref_map->peer_ref && refspec->force)
@@ -1763,7 +1763,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			if (!starts_with((*rmp)->peer_ref->name, "refs/") ||
 			    check_refname_format((*rmp)->peer_ref->name, 0)) {
 				struct ref *ignore = *rmp;
-				error("* Ignoring funny ref '%s' locally",
+				error(_("* Ignoring funny ref '%s' locally"),
 				      (*rmp)->peer_ref->name);
 				*rmp = (*rmp)->next;
 				free(ignore->peer_ref);
@@ -1858,7 +1858,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
 	repo_init_revisions(the_repository, &revs, NULL);
 	setup_revisions(argv.argc, argv.argv, &revs, NULL);
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	/* ... and count the commits on each side. */
 	while (1) {
@@ -2131,7 +2131,8 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
 	else if (!colon[1])
 		oidclr(&entry->expect);
 	else if (get_oid(colon + 1, &entry->expect))
-		return error("cannot parse expected object name '%s'", colon + 1);
+		return error(_("cannot parse expected object name '%s'"),
+			     colon + 1);
 	return 0;
 }
 
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 09/12] repack: mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (7 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 08/12] remote.c: mark messages " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 10/12] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/repack.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/builtin/repack.c b/builtin/repack.c
index c6a7943d5c..0af20fa0fc 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -197,7 +197,7 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack,
 
 	if (cmd->in == -1) {
 		if (start_command(cmd))
-			die("Could not start pack-objects to repack promisor objects");
+			die(_("could not start pack-objects to repack promisor objects"));
 	}
 
 	xwrite(cmd->in, oid_to_hex(oid), GIT_SHA1_HEXSZ);
@@ -236,7 +236,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 		char *promisor_name;
 		int fd;
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects."));
 		string_list_append(names, line.buf);
 
 		/*
@@ -247,13 +247,13 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 					  line.buf);
 		fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
 		if (fd < 0)
-			die_errno("unable to create '%s'", promisor_name);
+			die_errno(("unable to create '%s'"), promisor_name);
 		close(fd);
 		free(promisor_name);
 	}
 	fclose(out);
 	if (finish_command(&cmd))
-		die("Could not finish pack-objects to repack promisor objects");
+		die(_("could not finish pack-objects to repack promisor objects"));
 }
 
 #define ALL_INTO_ONE 1
@@ -408,7 +408,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	out = xfdopen(cmd.out, "r");
 	while (strbuf_getline_lf(&line, out) != EOF) {
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects"));
 		string_list_append(&names, line.buf);
 	}
 	fclose(out);
@@ -417,7 +417,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		return ret;
 
 	if (!names.nr && !po_args.quiet)
-		printf("Nothing new to pack.\n");
+		printf_ln(_("Nothing new to pack."));
 
 	/*
 	 * Ok we have prepared all new packfiles.
@@ -477,13 +477,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		if (rollback_failure.nr) {
 			int i;
 			fprintf(stderr,
-				"WARNING: Some packs in use have been renamed by\n"
-				"WARNING: prefixing old- to their name, in order to\n"
-				"WARNING: replace them with the new version of the\n"
-				"WARNING: file.  But the operation failed, and the\n"
-				"WARNING: attempt to rename them back to their\n"
-				"WARNING: original names also failed.\n"
-				"WARNING: Please rename them in %s manually:\n", packdir);
+				_("WARNING: Some packs in use have been renamed by\n"
+				  "WARNING: prefixing old- to their name, in order to\n"
+				  "WARNING: replace them with the new version of the\n"
+				  "WARNING: file.  But the operation failed, and the\n"
+				  "WARNING: attempt to rename them back to their\n"
+				  "WARNING: original names also failed.\n"
+				  "WARNING: Please rename them in %s manually:\n"), packdir);
 			for (i = 0; i < rollback_failure.nr; i++)
 				fprintf(stderr, "WARNING:   old-%s -> %s\n",
 					rollback_failure.items[i].string,
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 10/12] parse-options: replace opterror() with optname()
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (8 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 09/12] repack: mark more strings " Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 11/12] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

There are a few issues with opterror()

- it tries to assemble an English sentence from pieces. This is not
  great for translators because we give them pieces instead of a full
  sentence.

- It's a wrapper around error() and needs some hack to let the
  compiler know it always returns -1.

- Since it takes a string instead of printf format, one call site has
  to assemble the string manually before passing to it.

Kill it and produce the option name with optname(). The user will use
error() directly. This solves the second and third problems.

It kind helps the first problem as well because "%s does foo" does
give a translator a full sentence in a sense and let them reorder if
needed. But it has limitations, if the subject part has to change
based on the rest of the sentence, that language is screwed. This is
also why I try to avoid calling optname() when 'flags' is known in
advance.

Mark of these strings for translation as well while at there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge.c     |  2 +-
 builtin/revert.c    |  3 ++-
 parse-options-cb.c  |  7 ++++---
 parse-options.c     | 46 +++++++++++++++++++++++++--------------------
 parse-options.h     |  5 +----
 ref-filter.c        |  8 +++++---
 t/t4211-line-log.sh |  2 +-
 7 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 92ba7e1c6d..82248d43c3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -128,7 +128,7 @@ static int option_read_message(struct parse_opt_ctx_t *ctx,
 		ctx->argc--;
 		arg = *++ctx->argv;
 	} else
-		return opterror(opt, "requires a value", 0);
+		return error(_("option `%s' requires a value"), opt->long_name);
 
 	if (buf->len)
 		strbuf_addch(buf, '\n');
diff --git a/builtin/revert.c b/builtin/revert.c
index c93393c89b..11190d2ab4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -69,7 +69,8 @@ static int option_parse_m(const struct option *opt,
 
 	replay->mainline = strtol(arg, &end, 10);
 	if (*end || replay->mainline <= 0)
-		return opterror(opt, "expects a number greater than zero", 0);
+		return error(_("option `%s' expects a number greater than zero"),
+			     opt->long_name);
 
 	return 0;
 }
diff --git a/parse-options-cb.c b/parse-options-cb.c
index e8236534ac..813eb6301b 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -18,7 +18,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
 	} else {
 		v = strtol(arg, (char **)&arg, 10);
 		if (*arg)
-			return opterror(opt, "expects a numerical value", 0);
+			return error(_("option `%s' expects a numerical value"),
+				     opt->long_name);
 		if (v && v < MINIMUM_ABBREV)
 			v = MINIMUM_ABBREV;
 		else if (v > 40)
@@ -54,8 +55,8 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
 		arg = unset ? "never" : (const char *)opt->defval;
 	value = git_config_colorbool(NULL, arg);
 	if (value < 0)
-		return opterror(opt,
-			"expects \"always\", \"auto\", or \"never\"", 0);
+		return error(_("option `%s' expects \"always\", \"auto\", or \"never\""),
+			     opt->long_name);
 	*(int *)opt->value = value;
 	return 0;
 }
diff --git a/parse-options.c b/parse-options.c
index 3b874a83a0..0bf817193d 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -32,7 +32,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
 		p->argc--;
 		*arg = *++p->argv;
 	} else
-		return opterror(opt, "requires a value", flags);
+		return error(_("%s requires a value"), optname(opt, flags));
 	return 0;
 }
 
@@ -49,7 +49,6 @@ static int opt_command_mode_error(const struct option *opt,
 				  int flags)
 {
 	const struct option *that;
-	struct strbuf message = STRBUF_INIT;
 	struct strbuf that_name = STRBUF_INIT;
 
 	/*
@@ -67,13 +66,13 @@ static int opt_command_mode_error(const struct option *opt,
 			strbuf_addf(&that_name, "--%s", that->long_name);
 		else
 			strbuf_addf(&that_name, "-%c", that->short_name);
-		strbuf_addf(&message, ": incompatible with %s", that_name.buf);
+		error(_("%s is incompatible with %s"),
+		      optname(opt, flags), that_name.buf);
 		strbuf_release(&that_name);
-		opterror(opt, message.buf, flags);
-		strbuf_release(&message);
 		return -1;
 	}
-	return opterror(opt, ": incompatible with something else", flags);
+	return error(_("%s : incompatible with something else"),
+		     optname(opt, flags));
 }
 
 static int get_value(struct parse_opt_ctx_t *p,
@@ -86,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p,
 	int err;
 
 	if (unset && p->opt)
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 	if (unset && (opt->flags & PARSE_OPT_NONEG))
-		return opterror(opt, "isn't available", flags);
+		return error(_("%s isn't available"), optname(opt, flags));
 	if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 
 	switch (opt->type) {
 	case OPTION_LOWLEVEL_CALLBACK:
@@ -176,7 +175,8 @@ static int get_value(struct parse_opt_ctx_t *p,
 			return -1;
 		*(int *)opt->value = strtol(arg, (char **)&s, 10);
 		if (*s)
-			return opterror(opt, "expects a numerical value", flags);
+			return error(_("%s expects a numerical value"),
+				     optname(opt, flags));
 		return 0;
 
 	case OPTION_MAGNITUDE:
@@ -191,9 +191,9 @@ static int get_value(struct parse_opt_ctx_t *p,
 		if (get_arg(p, opt, flags, &arg))
 			return -1;
 		if (!git_parse_ulong(arg, opt->value))
-			return opterror(opt,
-				"expects a non-negative integer value with an optional k/m/g suffix",
-				flags);
+			return error(_("%s expects a non-negative integer value"
+				       " with an optional k/m/g suffix"),
+				     optname(opt, flags));
 		return 0;
 
 	default:
@@ -257,7 +257,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 			if (!rest)
 				continue;
 			if (*rest == '=')
-				return opterror(options, "takes no value", flags);
+				return error(_("%s takes no value"),
+					     optname(options, flags));
 			if (*rest)
 				continue;
 			p->out[p->cpidx++] = arg - 2;
@@ -773,12 +774,17 @@ void NORETURN usage_msg_opt(const char *msg,
 	usage_with_options(usagestr, options);
 }
 
-#undef opterror
-int opterror(const struct option *opt, const char *reason, int flags)
+const char *optname(const struct option *opt, int flags)
 {
+	static struct strbuf sb = STRBUF_INIT;
+
+	strbuf_reset(&sb);
 	if (flags & OPT_SHORT)
-		return error("switch `%c' %s", opt->short_name, reason);
-	if (flags & OPT_UNSET)
-		return error("option `no-%s' %s", opt->long_name, reason);
-	return error("option `%s' %s", opt->long_name, reason);
+		strbuf_addf(&sb, "switch `%c'", opt->short_name);
+	else if (flags & OPT_UNSET)
+		strbuf_addf(&sb, "option `no-%s'", opt->long_name);
+	else
+		strbuf_addf(&sb, "option `%s'", opt->long_name);
+
+	return sb.buf;
 }
diff --git a/parse-options.h b/parse-options.h
index dd14911a29..2e146aa6fa 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -189,10 +189,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
 				   const struct option *options);
 
 extern int optbug(const struct option *opt, const char *reason);
-extern int opterror(const struct option *opt, const char *reason, int flags);
-#if defined(__GNUC__)
-#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
-#endif
+const char *optname(const struct option *opt, int flags);
 
 /*----- incremental advanced APIs -----*/
 
diff --git a/ref-filter.c b/ref-filter.c
index 2a05619211..0681359100 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2302,9 +2302,11 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 
 	if (rf->merge) {
 		if (no_merged) {
-			return opterror(opt, "is incompatible with --merged", 0);
+			return error(_("option `%s' is incompatible with --merged"),
+				     opt->long_name);
 		} else {
-			return opterror(opt, "is incompatible with --no-merged", 0);
+			return error(_("option `%s' is incompatible with --no-merged"),
+				     opt->long_name);
 		}
 	}
 
@@ -2318,7 +2320,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 	rf->merge_commit = lookup_commit_reference_gently(the_repository,
 							  &oid, 0);
 	if (!rf->merge_commit)
-		return opterror(opt, "must point to a commit", 0);
+		return error(_("option `%s' must point to a commit"), opt->long_name);
 
 	return 0;
 }
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
index ef1322148e..bd5fe4d148 100755
--- a/t/t4211-line-log.sh
+++ b/t/t4211-line-log.sh
@@ -25,7 +25,7 @@ canned_test_failure () {
 test_bad_opts () {
 	test_expect_success "invalid args: $1" "
 		test_must_fail git log $1 2>errors &&
-		grep '$2' errors
+		test_i18ngrep '$2' errors
 	"
 }
 
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 11/12] parse-options.c: mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (9 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 10/12] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-28  6:51 ` [PATCH 12/12] fsck: mark " Nguyễn Thái Ngọc Duy
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
  12 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c          | 18 +++++++++---------
 t/t0040-parse-options.sh |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 0bf817193d..949aac287f 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -197,7 +197,7 @@ static int get_value(struct parse_opt_ctx_t *p,
 		return 0;
 
 	default:
-		die("should not happen, someone must be hit on the forehead");
+		BUG("opt->type %d should not happen, someone must be hit on the forehead", opt->type);
 	}
 }
 
@@ -319,8 +319,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 	}
 
 	if (ambiguous_option) {
-		error("Ambiguous option: %s "
-			"(could be --%s%s or --%s%s)",
+		error(_("ambiguous option: %s "
+			"(could be --%s%s or --%s%s)"),
 			arg,
 			(ambiguous_flags & OPT_UNSET) ?  "no-" : "",
 			ambiguous_option->long_name,
@@ -353,7 +353,7 @@ static void check_typos(const char *arg, const struct option *options)
 		return;
 
 	if (starts_with(arg, "no-")) {
-		error ("did you mean `--%s` (with two dashes ?)", arg);
+		error(_("did you mean `--%s` (with two dashes ?)"), arg);
 		exit(129);
 	}
 
@@ -361,7 +361,7 @@ static void check_typos(const char *arg, const struct option *options)
 		if (!options->long_name)
 			continue;
 		if (starts_with(options->long_name, arg)) {
-			error ("did you mean `--%s` (with two dashes ?)", arg);
+			error(_("did you mean `--%s` (with two dashes ?)"), arg);
 			exit(129);
 		}
 	}
@@ -424,7 +424,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
 	ctx->flags = flags;
 	if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
 	    (flags & PARSE_OPT_STOP_AT_NON_OPTION))
-		die("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
+		BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
 	parse_options_check(options);
 }
 
@@ -644,11 +644,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
 		break;
 	default: /* PARSE_OPT_UNKNOWN */
 		if (ctx.argv[0][1] == '-') {
-			error("unknown option `%s'", ctx.argv[0] + 2);
+			error(_("unknown option `%s'"), ctx.argv[0] + 2);
 		} else if (isascii(*ctx.opt)) {
-			error("unknown switch `%c'", *ctx.opt);
+			error(_("unknown switch `%c'"), *ctx.opt);
 		} else {
-			error("unknown non-ascii option in string: `%s'",
+			error(_("unknown non-ascii option in string: `%s'"),
 			      ctx.argv[0]);
 		}
 		usage_with_options(usagestr, options);
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 17d0c18feb..e46b1e02f0 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -228,7 +228,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -boolean >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 cat >typo.err <<\EOF
@@ -238,7 +238,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -ambiguous >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 test_expect_success 'keep some options as arguments' '
-- 
2.19.1.647.g708186aaf9


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

* [PATCH 12/12] fsck: mark strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (10 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 11/12] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-10-28  6:51 ` Nguyễn Thái Ngọc Duy
  2018-10-29 10:53   ` SZEDER Gábor
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
  12 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-10-28  6:51 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c             | 113 ++++++++++++++++++++-----------------
 t/t1410-reflog.sh          |   6 +-
 t/t1450-fsck.sh            |  50 ++++++++--------
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +-
 5 files changed, 94 insertions(+), 85 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 06eb421720..13f8fe35c5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -108,8 +108,9 @@ static int fsck_config(const char *var, const char *value, void *cb)
 static void objreport(struct object *obj, const char *msg_type,
 			const char *err)
 {
-	fprintf(stderr, "%s in %s %s: %s\n",
-		msg_type, printable_type(obj), describe_object(obj), err);
+	fprintf_ln(stderr, _("%s in %s %s: %s"),
+		   msg_type, printable_type(obj),
+		   describe_object(obj), err);
 }
 
 static int objerror(struct object *obj, const char *err)
@@ -139,17 +140,18 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 	 */
 	if (!obj) {
 		/* ... these references to parent->fld are safe here */
-		printf("broken link from %7s %s\n",
-			   printable_type(parent), describe_object(parent));
-		printf("broken link from %7s %s\n",
-			   (type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
+		printf_ln(_("broken link from %7s %s"),
+			  printable_type(parent), describe_object(parent));
+		printf_ln(_("broken link from %7s %s"),
+			  (type == OBJ_ANY ? _("unknown") : type_name(type)),
+			  _("unknown"));
 		errors_found |= ERROR_REACHABLE;
 		return 1;
 	}
 
 	if (type != OBJ_ANY && obj->type != type)
 		/* ... and the reference to parent is safe here */
-		objerror(parent, "wrong object type in link");
+		objerror(parent, _("wrong object type in link"));
 
 	if (obj->flags & REACHABLE)
 		return 0;
@@ -165,10 +167,12 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
-			printf("broken link from %7s %s\n",
-				 printable_type(parent), describe_object(parent));
-			printf("              to %7s %s\n",
-				 printable_type(obj), describe_object(obj));
+			printf_ln(_("broken link from %7s %s\n"
+				    "              to %7s %s"),
+				  printable_type(parent),
+				  describe_object(parent),
+				  printable_type(obj),
+				  describe_object(obj));
 			errors_found |= ERROR_REACHABLE;
 		}
 		return 1;
@@ -232,8 +236,8 @@ static void check_reachable_object(struct object *obj)
 			return;
 		if (has_object_pack(&obj->oid))
 			return; /* it is in pack - forget about it */
-		printf("missing %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("missing %s %s"), printable_type(obj),
+			  describe_object(obj));
 		errors_found |= ERROR_REACHABLE;
 		return;
 	}
@@ -258,8 +262,8 @@ static void check_unreachable_object(struct object *obj)
 	 * since this is something that is prunable.
 	 */
 	if (show_unreachable) {
-		printf("unreachable %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("unreachable %s %s"), printable_type(obj),
+			  describe_object(obj));
 		return;
 	}
 
@@ -277,8 +281,8 @@ static void check_unreachable_object(struct object *obj)
 	 */
 	if (!(obj->flags & USED)) {
 		if (show_dangling)
-			printf("dangling %s %s\n", printable_type(obj),
-			       describe_object(obj));
+			printf_ln(_("dangling %s %s"), printable_type(obj),
+				  describe_object(obj));
 		if (write_lost_and_found) {
 			char *filename = git_pathdup("lost-found/%s/%s",
 				obj->type == OBJ_COMMIT ? "commit" : "other",
@@ -286,18 +290,18 @@ static void check_unreachable_object(struct object *obj)
 			FILE *f;
 
 			if (safe_create_leading_directories_const(filename)) {
-				error("Could not create lost-found");
+				error(_("could not create lost-found"));
 				free(filename);
 				return;
 			}
 			f = xfopen(filename, "w");
 			if (obj->type == OBJ_BLOB) {
 				if (stream_blob_to_fd(fileno(f), &obj->oid, NULL, 1))
-					die_errno("Could not write '%s'", filename);
+					die_errno(_("could not write '%s'"), filename);
 			} else
 				fprintf(f, "%s\n", describe_object(obj));
 			if (fclose(f))
-				die_errno("Could not finish '%s'",
+				die_errno(_("could not finish '%s'"),
 					  filename);
 			free(filename);
 		}
@@ -314,7 +318,7 @@ static void check_unreachable_object(struct object *obj)
 static void check_object(struct object *obj)
 {
 	if (verbose)
-		fprintf(stderr, "Checking %s\n", describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s"), describe_object(obj));
 
 	if (obj->flags & REACHABLE)
 		check_reachable_object(obj);
@@ -332,7 +336,7 @@ static void check_connectivity(void)
 	/* Look up all the requirements, warn about missing objects.. */
 	max = get_max_object_index();
 	if (verbose)
-		fprintf(stderr, "Checking connectivity (%d objects)\n", max);
+		fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
 
 	for (i = 0; i < max; i++) {
 		struct object *obj = get_indexed_object(i);
@@ -351,11 +355,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 	obj->flags |= SEEN;
 
 	if (verbose)
-		fprintf(stderr, "Checking %s %s\n",
-			printable_type(obj), describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s %s"),
+			   printable_type(obj), describe_object(obj));
 
 	if (fsck_walk(obj, NULL, &fsck_obj_options))
-		objerror(obj, "broken links");
+		objerror(obj, _("broken links"));
 	err = fsck_object(obj, buffer, size, &fsck_obj_options);
 	if (err)
 		goto out;
@@ -364,17 +368,19 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 		struct commit *commit = (struct commit *) obj;
 
 		if (!commit->parents && show_root)
-			printf("root %s\n", describe_object(&commit->object));
+			printf_ln(_("root %s"),
+				  describe_object(&commit->object));
 	}
 
 	if (obj->type == OBJ_TAG) {
 		struct tag *tag = (struct tag *) obj;
 
 		if (show_tags && tag->tagged) {
-			printf("tagged %s %s", printable_type(tag->tagged),
-				describe_object(tag->tagged));
-			printf(" (%s) in %s\n", tag->tag,
-				describe_object(&tag->object));
+			printf(_("tagged %s %s (%s) in %s"),
+			       printable_type(tag->tagged),
+			       describe_object(tag->tagged),
+			       tag->tag,
+			       describe_object(&tag->object));
 		}
 	}
 
@@ -398,7 +404,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
 				  eaten);
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		return error("%s: object corrupt or missing", oid_to_hex(oid));
+		return error(_("%s: object corrupt or missing"),
+			     oid_to_hex(oid));
 	}
 	obj->flags &= ~(REACHABLE | SEEN);
 	obj->flags |= HAS_OBJ;
@@ -422,7 +429,8 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
 			obj->flags |= USED;
 			mark_object_reachable(obj);
 		} else if (!is_promisor_object(oid)) {
-			error("%s: invalid reflog entry %s", refname, oid_to_hex(oid));
+			error(_("%s: invalid reflog entry %s"),
+			      refname, oid_to_hex(oid));
 			errors_found |= ERROR_REACHABLE;
 		}
 	}
@@ -435,8 +443,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 	const char *refname = cb_data;
 
 	if (verbose)
-		fprintf(stderr, "Checking reflog %s->%s\n",
-			oid_to_hex(ooid), oid_to_hex(noid));
+		fprintf_ln(stderr, _("Checking reflog %s->%s"),
+			   oid_to_hex(ooid), oid_to_hex(noid));
 
 	fsck_handle_reflog_oid(refname, ooid, 0);
 	fsck_handle_reflog_oid(refname, noid, timestamp);
@@ -465,13 +473,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
 			 default_refs++;
 			 return 0;
 		}
-		error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
+		error(_("%s: invalid sha1 pointer %s"),
+		      refname, oid_to_hex(oid));
 		errors_found |= ERROR_REACHABLE;
 		/* We'll continue with the rest despite the error.. */
 		return 0;
 	}
 	if (obj->type != OBJ_COMMIT && is_branch(refname)) {
-		error("%s: not a commit", refname);
+		error(_("%s: not a commit"), refname);
 		errors_found |= ERROR_REFS;
 	}
 	default_refs++;
@@ -505,7 +514,7 @@ static void get_default_heads(void)
 	 * "show_unreachable" flag.
 	 */
 	if (!default_refs) {
-		fprintf(stderr, "notice: No default references\n");
+		fprintf_ln(stderr, _("notice: No default references"));
 		show_unreachable = 0;
 	}
 }
@@ -520,7 +529,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (read_loose_object(path, oid, &type, &size, &contents) < 0) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object corrupt or missing: %s",
+		error(_("%s: object corrupt or missing: %s"),
 		      oid_to_hex(oid), path);
 		return 0; /* keep checking other objects */
 	}
@@ -533,7 +542,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object could not be parsed: %s",
+		error(_("%s: object could not be parsed: %s"),
 		      oid_to_hex(oid), path);
 		if (!eaten)
 			free(contents);
@@ -553,7 +562,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 static int fsck_cruft(const char *basename, const char *path, void *data)
 {
 	if (!starts_with(basename, "tmp_obj_"))
-		fprintf(stderr, "bad sha1 file: %s\n", path);
+		fprintf_ln(stderr, _("bad sha1 file: %s"), path);
 	return 0;
 }
 
@@ -568,7 +577,7 @@ static void fsck_object_dir(const char *path)
 	struct progress *progress = NULL;
 
 	if (verbose)
-		fprintf(stderr, "Checking object directory\n");
+		fprintf_ln(stderr, _("Checking object directory"));
 
 	if (show_progress)
 		progress = start_progress(_("Checking object directories"), 256);
@@ -584,28 +593,28 @@ static int fsck_head_link(void)
 	int null_is_error = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking HEAD link\n");
+		fprintf_ln(stderr, _("Checking HEAD link"));
 
 	head_points_at = resolve_ref_unsafe("HEAD", 0, &head_oid, NULL);
 	if (!head_points_at) {
 		errors_found |= ERROR_REFS;
-		return error("Invalid HEAD");
+		return error(_("invalid HEAD"));
 	}
 	if (!strcmp(head_points_at, "HEAD"))
 		/* detached HEAD */
 		null_is_error = 1;
 	else if (!starts_with(head_points_at, "refs/heads/")) {
 		errors_found |= ERROR_REFS;
-		return error("HEAD points to something strange (%s)",
+		return error(_("HEAD points to something strange (%s)"),
 			     head_points_at);
 	}
 	if (is_null_oid(&head_oid)) {
 		if (null_is_error) {
 			errors_found |= ERROR_REFS;
-			return error("HEAD: detached HEAD points at nothing");
+			return error(_("HEAD: detached HEAD points at nothing"));
 		}
-		fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
-			head_points_at + 11);
+		fprintf_ln(stderr, _("notice: HEAD points to an unborn branch (%s)"),
+			   head_points_at + 11);
 	}
 	return 0;
 }
@@ -616,12 +625,12 @@ static int fsck_cache_tree(struct cache_tree *it)
 	int err = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking cache tree\n");
+		fprintf_ln(stderr, _("Checking cache tree"));
 
 	if (0 <= it->entry_count) {
 		struct object *obj = parse_object(the_repository, &it->oid);
 		if (!obj) {
-			error("%s: invalid sha1 pointer in cache-tree",
+			error(_("%s: invalid sha1 pointer in cache-tree"),
 			      oid_to_hex(&it->oid));
 			errors_found |= ERROR_REFS;
 			return 1;
@@ -632,7 +641,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 				obj, xstrdup(":"));
 		mark_object_reachable(obj);
 		if (obj->type != OBJ_TREE)
-			err |= objerror(obj, "non-tree in cache-tree");
+			err |= objerror(obj, _("non-tree in cache-tree"));
 	}
 	for (i = 0; i < it->subtree_nr; i++)
 		err |= fsck_cache_tree(it->down[i]->cache_tree);
@@ -774,7 +783,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			if (!obj || !(obj->flags & HAS_OBJ)) {
 				if (is_promisor_object(&oid))
 					continue;
-				error("%s: object missing", oid_to_hex(&oid));
+				error(_("%s: object missing"), oid_to_hex(&oid));
 				errors_found |= ERROR_OBJECT;
 				continue;
 			}
@@ -786,7 +795,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			mark_object_reachable(obj);
 			continue;
 		}
-		error("invalid parameter: expected sha1, got '%s'", arg);
+		error(_("invalid parameter: expected sha1, got '%s'"), arg);
 		errors_found |= ERROR_OBJECT;
 	}
 
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 388b0611d8..353bdfd415 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -20,12 +20,12 @@ check_have () {
 }
 
 check_fsck () {
-	output=$(git fsck --full)
+	git fsck --full >fsck.output
 	case "$1" in
 	'')
-		test -z "$output" ;;
+		test_must_be_empty fsck.output ;;
 	*)
-		echo "$output" | grep "$1" ;;
+		test_i18ngrep "$1" fsck.output ;;
 	esac
 }
 
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 90c765df3a..500c21366e 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -70,7 +70,7 @@ test_expect_success 'object with bad sha1' '
 
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "$sha.*corrupt" out
+	test_i18ngrep "$sha.*corrupt" out
 '
 
 test_expect_success 'branch pointing to non-commit' '
@@ -78,7 +78,7 @@ test_expect_success 'branch pointing to non-commit' '
 	test_when_finished "git update-ref -d refs/heads/invalid" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "not a commit" out
+	test_i18ngrep "not a commit" out
 '
 
 test_expect_success 'HEAD link pointing at a funny object' '
@@ -88,7 +88,7 @@ test_expect_success 'HEAD link pointing at a funny object' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "detached HEAD points" out
+	test_i18ngrep "detached HEAD points" out
 '
 
 test_expect_success 'HEAD link pointing at a funny place' '
@@ -98,7 +98,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "HEAD points to something strange" out
+	test_i18ngrep "HEAD points to something strange" out
 '
 
 test_expect_success 'email without @ is okay' '
@@ -122,7 +122,7 @@ test_expect_success 'email with embedded > is not okay' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 test_expect_success 'missing < email delimiter is reported nicely' '
@@ -134,7 +134,7 @@ test_expect_success 'missing < email delimiter is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - bad name" out
+	test_i18ngrep "error in commit $new.* - bad name" out
 '
 
 test_expect_success 'missing email is reported nicely' '
@@ -146,7 +146,7 @@ test_expect_success 'missing email is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - missing email" out
+	test_i18ngrep "error in commit $new.* - missing email" out
 '
 
 test_expect_success '> in name is reported' '
@@ -158,7 +158,7 @@ test_expect_success '> in name is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 # date is 2^64 + 1
@@ -172,7 +172,7 @@ test_expect_success 'integer overflow in timestamps is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*integer overflow" out
+	test_i18ngrep "error in commit $new.*integer overflow" out
 '
 
 test_expect_success 'commit with NUL in header' '
@@ -184,7 +184,7 @@ test_expect_success 'commit with NUL in header' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'tree object with duplicate entries' '
@@ -205,7 +205,7 @@ test_expect_success 'tree object with duplicate entries' '
 		git hash-object -w -t tree --stdin
 	) &&
 	test_must_fail git fsck 2>out &&
-	grep "error in tree .*contains duplicate file entries" out
+	test_i18ngrep "error in tree .*contains duplicate file entries" out
 '
 
 test_expect_success 'unparseable tree object' '
@@ -259,7 +259,7 @@ test_expect_success 'tag pointing to nonexistent' '
 	test_when_finished "git update-ref -d refs/tags/invalid" &&
 	test_must_fail git fsck --tags >out &&
 	cat out &&
-	grep "broken link" out
+	test_i18ngrep "broken link" out
 '
 
 test_expect_success 'tag pointing to something else than its type' '
@@ -301,7 +301,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' '
 	warning in tag $tag: badTagName: invalid '\''tag'\'' name: wrong name format
 	warning in tag $tag: missingTaggerEntry: invalid format - expected '\''tagger'\'' line
 	EOF
-	test_cmp expect out
+	test_i18ncmp expect out
 '
 
 test_expect_success 'tag with bad tagger' '
@@ -320,7 +320,7 @@ test_expect_success 'tag with bad tagger' '
 	echo $tag >.git/refs/tags/wrong &&
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
-	grep "error in tag .*: invalid author/committer" out
+	test_i18ngrep "error in tag .*: invalid author/committer" out
 '
 
 test_expect_success 'tag with NUL in header' '
@@ -340,7 +340,7 @@ test_expect_success 'tag with NUL in header' '
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
 	cat out &&
-	grep "error in tag $tag.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'cleaned up' '
@@ -396,7 +396,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -407,7 +407,7 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -428,7 +428,7 @@ while read name path pretty; do
 			bad_tree=$(git mktree <bad) &&
 			git fsck 2>out &&
 			cat out &&
-			grep "warning.*tree $bad_tree" out
+			test_i18ngrep "warning.*tree $bad_tree" out
 		)'
 	done <<-\EOF
 	100644 blob
@@ -474,9 +474,9 @@ test_expect_success 'NUL in commit' '
 		git branch bad $(cat name) &&
 
 		test_must_fail git -c fsck.nulInCommit=error fsck 2>warn.1 &&
-		grep nulInCommit warn.1 &&
+		test_i18ngrep nulInCommit warn.1 &&
 		git fsck 2>warn.2 &&
-		grep nulInCommit warn.2
+		test_i18ngrep nulInCommit warn.2
 	)
 '
 
@@ -594,7 +594,7 @@ test_expect_success 'fsck --name-objects' '
 		remove_object $(git rev-parse julius:caesar.t) &&
 		test_must_fail git fsck --name-objects >out &&
 		tree=$(git rev-parse --verify julius:) &&
-		egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
+		test -n "$GETTEXT_POISON" || egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
 	)
 '
 
@@ -605,7 +605,7 @@ test_expect_success 'alternate objects are correctly blamed' '
 	mkdir alt.git/objects/12 &&
 	>alt.git/objects/12/34567890123456789012345678901234567890 &&
 	test_must_fail git fsck >out 2>&1 &&
-	grep alt.git out
+	test_i18ngrep alt.git out
 '
 
 test_expect_success 'fsck errors in packed objects' '
@@ -624,8 +624,8 @@ test_expect_success 'fsck errors in packed objects' '
 	remove_object $one &&
 	remove_object $two &&
 	test_must_fail git fsck 2>out &&
-	grep "error in commit $one.* - bad name" out &&
-	grep "error in commit $two.* - bad name" out &&
+	test_i18ngrep "error in commit $one.* - bad name" out &&
+	test_i18ngrep "error in commit $two.* - bad name" out &&
 	! grep corrupt out
 '
 
@@ -706,7 +706,7 @@ test_expect_success 'fsck notices dangling objects' '
 		git fsck >actual &&
 		# the output order is non-deterministic, as it comes from a hash
 		sort <actual >actual.sorted &&
-		test_cmp expect actual.sorted
+		test_i18ncmp expect actual.sorted
 	)
 '
 
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 86374a9c52..7700a8e793 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -133,8 +133,8 @@ test_expect_success 'tag replaced commit' '
 
 test_expect_success '"git fsck" works' '
      git fsck master >fsck_master.out &&
-     grep "dangling commit $R" fsck_master.out &&
-     grep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
+     test_i18ngrep "dangling commit $R" fsck_master.out &&
+     test_i18ngrep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
      test -z "$(git fsck)"
 '
 
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index 293e2e1963..49a37efe9c 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -154,7 +154,7 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
 		# symlink detector; this grep string comes from the config
 		# variable name and will not be translated.
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesSymlink output
+		test_i18ngrep gitmodulesSymlink output
 	)
 '
 
@@ -172,7 +172,7 @@ test_expect_success 'fsck detects non-blob .gitmodules' '
 		git ls-tree HEAD | sed s/subdir/.gitmodules/ | git mktree &&
 
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesBlob output
+		test_i18ngrep gitmodulesBlob output
 	)
 '
 
@@ -186,7 +186,7 @@ test_expect_success 'fsck detects corrupt .gitmodules' '
 		git commit -m "broken gitmodules" &&
 
 		git fsck 2>output &&
-		grep gitmodulesParse output &&
+		test_i18ngrep gitmodulesParse output &&
 		test_i18ngrep ! "bad config" output
 	)
 '
-- 
2.19.1.647.g708186aaf9


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

* Re: [PATCH 08/12] remote.c: mark messages for translation
  2018-10-28  6:51 ` [PATCH 08/12] remote.c: mark messages " Nguyễn Thái Ngọc Duy
@ 2018-10-29  7:56   ` Junio C Hamano
  2018-10-29 16:16     ` Duy Nguyen
  0 siblings, 1 reply; 71+ messages in thread
From: Junio C Hamano @ 2018-10-29  7:56 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> @@ -995,12 +995,12 @@ static int match_explicit_lhs(struct ref *src,
>  		 * way to delete 'other' ref at the remote end.
>  		 */
>  		if (try_explicit_object_name(rs->src, match) < 0)
> -			return error("src refspec %s does not match any.", rs->src);
> +			return error(_("src refspec %s does not match any"), rs->src);
>  		if (allocated_match)
>  			*allocated_match = 1;
>  		return 0;
>  	default:
> -		return error("src refspec %s matches more than one.", rs->src);
> +		return error(_("src refspec %s matches more than one"), rs->src);
>  	}
>  }

These minor changes that are not accompanied by their own
justification mean that the patches in this series cannot blindly be
trusted, which in turn means that I won't have bandwidth to process
this series properly for now.

I also saw die() -> BUG() that was not highlighted in the proposed
log message; the single instance I happened to notice looked
sensible, but I am not sure about the others.

There are other series in flight that touch the same area of code
and in different ways, causing unnecessary conflicts, which does not
help us either X-<.



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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-28  6:51 ` [PATCH 12/12] fsck: mark " Nguyễn Thái Ngọc Duy
@ 2018-10-29 10:53   ` SZEDER Gábor
  2018-10-29 14:09     ` Junio C Hamano
  2018-11-05 17:21     ` Duy Nguyen
  0 siblings, 2 replies; 71+ messages in thread
From: SZEDER Gábor @ 2018-10-29 10:53 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

On Sun, Oct 28, 2018 at 07:51:57AM +0100, Nguyễn Thái Ngọc Duy wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/fsck.c             | 113 ++++++++++++++++++++-----------------
>  t/t1410-reflog.sh          |   6 +-
>  t/t1450-fsck.sh            |  50 ++++++++--------
>  t/t6050-replace.sh         |   4 +-
>  t/t7415-submodule-names.sh |   6 +-
>  5 files changed, 94 insertions(+), 85 deletions(-)
> 
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 06eb421720..13f8fe35c5 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -108,8 +108,9 @@ static int fsck_config(const char *var, const char *value, void *cb)
>  static void objreport(struct object *obj, const char *msg_type,
>  			const char *err)
>  {
> -	fprintf(stderr, "%s in %s %s: %s\n",
> -		msg_type, printable_type(obj), describe_object(obj), err);
> +	fprintf_ln(stderr, _("%s in %s %s: %s"),

Are the (f)printf() -> (f)printf_ln() changes all over
'builtin/fsck.c' really necessary to mark strings for translation?

> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index 90c765df3a..500c21366e 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh

> @@ -594,7 +594,7 @@ test_expect_success 'fsck --name-objects' '
>  		remove_object $(git rev-parse julius:caesar.t) &&
>  		test_must_fail git fsck --name-objects >out &&
>  		tree=$(git rev-parse --verify julius:) &&
> -		egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
> +		test -n "$GETTEXT_POISON" || egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out

'test_i18ngrep' accepts all 'grep' options, so this could be written
as:

  test_i18ngrep -E "..." out


There might be something else wrong with the patch, because now this
test tends to fail on current 'pu' on Travis CI:

  [... snipped output from 'test_commit' ...]
  +git rev-parse julius:caesar.t
  +remove_object be45bbd3809e0829297cefa576e699c134abacfd
  +sha1_file be45bbd3809e0829297cefa576e699c134abacfd
  +remainder=45bbd3809e0829297cefa576e699c134abacfd
  +firsttwo=be
  +echo .git/objects/be/45bbd3809e0829297cefa576e699c134abacfd
  +rm .git/objects/be/45bbd3809e0829297cefa576e699c134abacfd
  +test_must_fail git fsck --name-objects
  +_test_ok=
  +git fsck --name-objects
  +exit_code=2
  +test 2 -eq 0
  +test_match_signal 13 2
  +test 2 = 141
  +test 2 = 269
  +return 1
  +test 2 -gt 129
  +test 2 -eq 127
  +test 2 -eq 126
  +return 0
  +git rev-parse --verify julius:
  +tree=c2fab98f409a47394d992eca10a20e0b22377c0c
  +test -n 
  +egrep c2fab98f409a47394d992eca10a20e0b22377c0c \((refs/heads/master|HEAD)@\{[0-9]*\}: out
  error: last command exited with $?=1
  not ok 65 - fsck --name-objects

The contents of 'out':

  broken link from    tree be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)
                to    blob be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)
  missing blob be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)

On a related (side)note, I think it would be better if this 'grep'
pattern were more explicit about which of the three lines it is
supposed to match.


Anyway, I couldn't reproduce the failure locally yet, but, admittedly,
I didn't try that hard...  And my builds on Travis CI haven't yet come
that far to try this topic on its own.


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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 10:53   ` SZEDER Gábor
@ 2018-10-29 14:09     ` Junio C Hamano
  2018-10-29 16:14       ` Duy Nguyen
  2018-11-05 17:21     ` Duy Nguyen
  1 sibling, 1 reply; 71+ messages in thread
From: Junio C Hamano @ 2018-10-29 14:09 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Nguyễn Thái Ngọc Duy, git

SZEDER Gábor <szeder.dev@gmail.com> writes:

>> -	fprintf(stderr, "%s in %s %s: %s\n",
>> -		msg_type, printable_type(obj), describe_object(obj), err);
>> +	fprintf_ln(stderr, _("%s in %s %s: %s"),
>
> Are the (f)printf() -> (f)printf_ln() changes all over
> 'builtin/fsck.c' really necessary to mark strings for translation?

It is beyond absolute minimum but I saw it argued here that this
makes it easier to manage the .po and .pot files if your message
strings do not end with LF, a you are much less likely to _add_
unneeded LF to the translated string than _lose_ LF at the end of
translated string.

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 14:09     ` Junio C Hamano
@ 2018-10-29 16:14       ` Duy Nguyen
  2018-10-29 17:38         ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 71+ messages in thread
From: Duy Nguyen @ 2018-10-29 16:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: SZEDER Gábor, Git Mailing List

On Mon, Oct 29, 2018 at 3:09 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> SZEDER Gábor <szeder.dev@gmail.com> writes:
>
> >> -    fprintf(stderr, "%s in %s %s: %s\n",
> >> -            msg_type, printable_type(obj), describe_object(obj), err);
> >> +    fprintf_ln(stderr, _("%s in %s %s: %s"),
> >
> > Are the (f)printf() -> (f)printf_ln() changes all over
> > 'builtin/fsck.c' really necessary to mark strings for translation?
>
> It is beyond absolute minimum but I saw it argued here that this
> makes it easier to manage the .po and .pot files if your message
> strings do not end with LF, a you are much less likely to _add_
> unneeded LF to the translated string than _lose_ LF at the end of
> translated string.

Especially when \n plays an important role and we don't trust
translators to keep it [1] [2]. It's probably a too defensive stance
and often does not apply, so nowadays I do it just to keep a
consistent pattern in the code.

[1] https://public-inbox.org/git/20120308220131.GA10122@burratino/#t
[2] but then translators can crash programs anyway (e.g. changing %d
to %s...) we just trust gettext tools to catch problems early.
-- 
Duy

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

* Re: [PATCH 08/12] remote.c: mark messages for translation
  2018-10-29  7:56   ` Junio C Hamano
@ 2018-10-29 16:16     ` Duy Nguyen
  0 siblings, 0 replies; 71+ messages in thread
From: Duy Nguyen @ 2018-10-29 16:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Mon, Oct 29, 2018 at 8:56 AM Junio C Hamano <gitster@pobox.com> wrote:
> There are other series in flight that touch the same area of code
> and in different ways, causing unnecessary conflicts, which does not
> help us either X-<.

I will of course fix all other comments, but I can hold this off if
it's causing too much trouble. I'm in no hurry to get anything merged
fast.
-- 
Duy

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 16:14       ` Duy Nguyen
@ 2018-10-29 17:38         ` Ævar Arnfjörð Bjarmason
  2018-10-29 17:43           ` Ævar Arnfjörð Bjarmason
  2018-10-30 23:27           ` Jonathan Nieder
  0 siblings, 2 replies; 71+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-10-29 17:38 UTC (permalink / raw)
  To: Duy Nguyen
  Cc: Junio C Hamano, SZEDER Gábor, Git Mailing List,
	Jonathan Nieder


On Mon, Oct 29 2018, Duy Nguyen wrote:

> On Mon, Oct 29, 2018 at 3:09 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> SZEDER Gábor <szeder.dev@gmail.com> writes:
>>
>> >> -    fprintf(stderr, "%s in %s %s: %s\n",
>> >> -            msg_type, printable_type(obj), describe_object(obj), err);
>> >> +    fprintf_ln(stderr, _("%s in %s %s: %s"),
>> >
>> > Are the (f)printf() -> (f)printf_ln() changes all over
>> > 'builtin/fsck.c' really necessary to mark strings for translation?
>>
>> It is beyond absolute minimum but I saw it argued here that this
>> makes it easier to manage the .po and .pot files if your message
>> strings do not end with LF, a you are much less likely to _add_
>> unneeded LF to the translated string than _lose_ LF at the end of
>> translated string.
>
> Especially when \n plays an important role and we don't trust
> translators to keep it [1] [2]. It's probably a too defensive stance
> and often does not apply, so nowadays I do it just to keep a
> consistent pattern in the code.
>
> [1] https://public-inbox.org/git/20120308220131.GA10122@burratino/#t
> [2] but then translators can crash programs anyway (e.g. changing %d
> to %s...) we just trust gettext tools to catch problems early.

As Jonathan pointed out in the follow-up message[1] this sort of thing
is checked for in msgfmt, so sure, let's strip the \n, but it's really
not something we need to worry about. Likewise with translators turning
"%s" into "%d" (or "% s") or whatever.

    $ git diff -U0
    diff --git a/po/de.po b/po/de.po
    index 47986814c9..62de46c63d 100644
    --- a/po/de.po
    +++ b/po/de.po
    @@ -23 +23 @@ msgid "%shint: %.*s%s\n"
    -msgstr "%sHinweis: %.*s%s\n"
    +msgstr "%sHinweis: %.*s%s"
    $ make [...]
    [...]
    po/de.po:23: 'msgid' and 'msgstr' entries do not both end with '\n'
    msgfmt: found 1 fatal error
    3470 translated messages.
    make: *** [Makefile:2488: po/build/locale/de/LC_MESSAGES/git.mo] Error 1

1. https://public-inbox.org/git/CACsJy8AcUy9FZiiehGc7mEL4i+XP6u0pmH1rGoR-WZnhYT1UMQ@mail.gmail.com/

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 17:38         ` Ævar Arnfjörð Bjarmason
@ 2018-10-29 17:43           ` Ævar Arnfjörð Bjarmason
  2018-11-01  1:36             ` Jiang Xin
  2018-10-30 23:27           ` Jonathan Nieder
  1 sibling, 1 reply; 71+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-10-29 17:43 UTC (permalink / raw)
  To: Duy Nguyen
  Cc: Junio C Hamano, SZEDER Gábor, Git Mailing List,
	Jonathan Nieder, Jiang Xin


On Mon, Oct 29 2018, Ævar Arnfjörð Bjarmason wrote:

> On Mon, Oct 29 2018, Duy Nguyen wrote:
>
>> On Mon, Oct 29, 2018 at 3:09 PM Junio C Hamano <gitster@pobox.com> wrote:
>>>
>>> SZEDER Gábor <szeder.dev@gmail.com> writes:
>>>
>>> >> -    fprintf(stderr, "%s in %s %s: %s\n",
>>> >> -            msg_type, printable_type(obj), describe_object(obj), err);
>>> >> +    fprintf_ln(stderr, _("%s in %s %s: %s"),
>>> >
>>> > Are the (f)printf() -> (f)printf_ln() changes all over
>>> > 'builtin/fsck.c' really necessary to mark strings for translation?
>>>
>>> It is beyond absolute minimum but I saw it argued here that this
>>> makes it easier to manage the .po and .pot files if your message
>>> strings do not end with LF, a you are much less likely to _add_
>>> unneeded LF to the translated string than _lose_ LF at the end of
>>> translated string.
>>
>> Especially when \n plays an important role and we don't trust
>> translators to keep it [1] [2]. It's probably a too defensive stance
>> and often does not apply, so nowadays I do it just to keep a
>> consistent pattern in the code.
>>
>> [1] https://public-inbox.org/git/20120308220131.GA10122@burratino/#t
>> [2] but then translators can crash programs anyway (e.g. changing %d
>> to %s...) we just trust gettext tools to catch problems early.
>
> As Jonathan pointed out in the follow-up message[1] this sort of thing
> is checked for in msgfmt, so sure, let's strip the \n, but it's really
> not something we need to worry about. Likewise with translators turning
> "%s" into "%d" (or "% s") or whatever.
>
>     $ git diff -U0
>     diff --git a/po/de.po b/po/de.po
>     index 47986814c9..62de46c63d 100644
>     --- a/po/de.po
>     +++ b/po/de.po
>     @@ -23 +23 @@ msgid "%shint: %.*s%s\n"
>     -msgstr "%sHinweis: %.*s%s\n"
>     +msgstr "%sHinweis: %.*s%s"
>     $ make [...]
>     [...]
>     po/de.po:23: 'msgid' and 'msgstr' entries do not both end with '\n'
>     msgfmt: found 1 fatal error
>     3470 translated messages.
>     make: *** [Makefile:2488: po/build/locale/de/LC_MESSAGES/git.mo] Error 1
>
> 1. https://public-inbox.org/git/CACsJy8AcUy9FZiiehGc7mEL4i+XP6u0pmH1rGoR-WZnhYT1UMQ@mail.gmail.com/

...to add to that, if there *are* formatting errors that --check doesn't
spot let's hear about it so we can just patch gettext upstream:
https://github.com/autotools-mirror/gettext/blob/master/gettext-tools/src/msgl-check.c#L572-L756

Unlike the rest of our stack where we need to support however many years
old tools we can freely rely on bleeding-edge gettext features, since
the only person we need to convince to upgrade is Jiang. I.e. he accepts
the PRs from translators, (presumably) runs msgfmt --check and then
submits the result to Junio.

See the "Usually..." paragraph in my 66f5f6dca9 ("C style: use standard
style for "TRANSLATORS" comments", 2017-05-11) for an example. We
already rely on a fairly recent gettext toolchain.

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 17:38         ` Ævar Arnfjörð Bjarmason
  2018-10-29 17:43           ` Ævar Arnfjörð Bjarmason
@ 2018-10-30 23:27           ` Jonathan Nieder
  1 sibling, 0 replies; 71+ messages in thread
From: Jonathan Nieder @ 2018-10-30 23:27 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Duy Nguyen, Junio C Hamano, SZEDER Gábor, Git Mailing List

Hi,

Ævar Arnfjörð Bjarmason wrote:
>> On Mon, Oct 29, 2018 at 3:09 PM Junio C Hamano <gitster@pobox.com> wrote:
>>> SZEDER Gábor <szeder.dev@gmail.com> writes:
>>>> Nguyễn Thái Ngọc Duy wrote:

>>>>> -    fprintf(stderr, "%s in %s %s: %s\n",
>>>>> -            msg_type, printable_type(obj), describe_object(obj), err);
>>>>> +    fprintf_ln(stderr, _("%s in %s %s: %s"),
>>>>
>>>> Are the (f)printf() -> (f)printf_ln() changes all over
>>>> 'builtin/fsck.c' really necessary to mark strings for translation?
>>>
>>> It is beyond absolute minimum but I saw it argued here that this
>>> makes it easier to manage the .po and .pot files if your message
>>> strings do not end with LF, a you are much less likely to _add_
>>> unneeded LF to the translated string than _lose_ LF at the end of
>>> translated string.
[...]
> As Jonathan pointed out in the follow-up message[1] this sort of thing
> is checked for in msgfmt, so sure, let's strip the \n, but it's really
> not something we need to worry about. Likewise with translators turning
> "%s" into "%d" (or "% s") or whatever.

IMHO the advantage of leaving the \n out in the message is not so much
that we don't trust translators but more that where we can make their
lives easier, we should.

In other words, I'm glad the patch does that, and Ævar, I agree.

Thanks, both.

Jonathan

> 1. https://public-inbox.org/git/CACsJy8AcUy9FZiiehGc7mEL4i+XP6u0pmH1rGoR-WZnhYT1UMQ@mail.gmail.com/

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 17:43           ` Ævar Arnfjörð Bjarmason
@ 2018-11-01  1:36             ` Jiang Xin
  0 siblings, 0 replies; 71+ messages in thread
From: Jiang Xin @ 2018-11-01  1:36 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Nguyen Thai Ngoc Duy, Junio C Hamano, szeder.dev, Git List,
	Jonathan Nieder

Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于2018年10月30日周二 上午1:43写道:
> On Mon, Oct 29 2018, Ævar Arnfjörð Bjarmason wrote:
> Unlike the rest of our stack where we need to support however many years
> old tools we can freely rely on bleeding-edge gettext features, since
> the only person we need to convince to upgrade is Jiang. I.e. he accepts
> the PRs from translators, (presumably) runs msgfmt --check and then
> submits the result to Junio.

I used a shell script to check commits before I send a pull request to Junio.
This script is in the po-helper branch, see:
https://github.com/git-l10n/git-po/tree/po-helper

It can catch unmatched '\n' errors (missing or unnecessary '\n').

    $ git diff
   diff --git a/po/zh_CN.po b/po/zh_CN.po
   index eabd4d1f8e..6b0d9ebc60 100644
   --- a/po/zh_CN.po
   +++ b/po/zh_CN.po
   @@ -5157,7 +5157,7 @@ msgstr  "略过补丁 '%s'。"
    #
    #, perl-format
    msgid   "Skipping %s with backup suffix '%s'.\n"
   -msgstr  "略过 %s 含备份后缀 '%s'。\n"
   +msgstr  "略过 %s 含备份后缀 '%s'。"
    #
    #, c-format
    msgid   "Skipping repository %s\n"

   $ LC_ALL=C po-helper.sh check
   ------------------------------------------------------------
   bg.po     : 3958 translated messages.
   ca.po     : 3328 translated messages, 18 fuzzy translations, 30
untranslated messages.
   de.po     : 3958 translated messages.
   es.po     : 3958 translated messages.
   fr.po     : 3957 translated messages, 1 fuzzy translation.
   is.po     : 14 translated messages.
   it.po     : 716 translated messages, 350 untranslated messages.
   ko.po     : 3608 translated messages.
   pt_PT.po  : 3198 translated messages.
   ru.po     : 3366 translated messages, 594 untranslated messages.
   sv.po     : 3958 translated messages.
   vi.po     : 3958 translated messages.
   zh_CN.po  : po/zh_CN.po:19717: 'msgid' and 'msgstr' entries do not
both end with '\n'
   msgfmt: found 1 fatal error
   3958 translated messages.
   ------------------------------------------------------------
   Show updates of git.pot...

   # Nothing changed. (run 'make pot' first)
   ------------------------------------------------------------
   Check commits...

   0 commits checked complete.
   ------------------------------------------------------------
   Note: If you want to check for upstream l10n update, run:
   Note:
   Note:     po-helper.sh check update <remote>
   ------------------------------------------------------------

So, no warry about it. BTW, I agree with Jonathan.

> Jonathan said:
> IMHO the advantage of leaving the \n out in the message is not so much
> that we don't trust translators but more that where we can make their
> lives easier, we should.

--
Jiang Xin

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

* Re: [PATCH 12/12] fsck: mark strings for translation
  2018-10-29 10:53   ` SZEDER Gábor
  2018-10-29 14:09     ` Junio C Hamano
@ 2018-11-05 17:21     ` Duy Nguyen
  1 sibling, 0 replies; 71+ messages in thread
From: Duy Nguyen @ 2018-11-05 17:21 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Git Mailing List

On Mon, Oct 29, 2018 at 12:53 PM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> The contents of 'out':
>
>   broken link from    tree be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)
>                 to    blob be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)
>   missing blob be45bbd3809e0829297cefa576e699c134abacfd (refs/heads/master@{1112912113}:caesar.t)
>
> On a related (side)note, I think it would be better if this 'grep'

I found the problem. Some function returns static string which works
fine when we do two printf()'s, one call of that function per
printf(). But when combining two printf() in one, we have a problem.
Thanks for catching.
-- 
Duy

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

* [PATCH v2 00/16] Mark more strings for translation
  2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
                   ` (11 preceding siblings ...)
  2018-10-28  6:51 ` [PATCH 12/12] fsck: mark " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20 ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
                     ` (16 more replies)
  12 siblings, 17 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

v2 splits non-trivial changes out to keep i18n patches simpler. A few
more word legos in fsck are removed. v2 also fixes a bug in fsck that
makes it print object id incorrectly.

Nguyễn Thái Ngọc Duy (16):
  git.c: mark more strings for translation
  alias.c: mark split_cmdline_strerror() strings for translation
  archive.c: mark more strings for translation
  attr.c: mark more string for translation
  read-cache.c: turn die("internal error") to BUG()
  read-cache.c: mark more strings for translation
  read-cache.c: add missing colon separators
  reflog: mark strings for translation
  remote.c: turn some error() or die() to BUG()
  remote.c: mark messages for translation
  repack: mark more strings for translation
  parse-options: replace opterror() with optname()
  parse-options.c: turn some die() to BUG()
  parse-options.c: mark more strings for translation
  fsck: reduce word legos to help i18n
  fsck: mark strings for translation

 alias.c                    |   4 +-
 archive.c                  |   8 +-
 attr.c                     |   4 +-
 builtin/fsck.c             | 156 +++++++++++++++++++++----------------
 builtin/merge.c            |   4 +-
 builtin/reflog.c           |  34 ++++----
 builtin/repack.c           |  26 +++----
 builtin/revert.c           |   3 +-
 git.c                      |  32 ++++----
 parse-options-cb.c         |   7 +-
 parse-options.c            |  64 ++++++++-------
 parse-options.h            |   5 +-
 read-cache.c               |  73 ++++++++---------
 ref-filter.c               |   8 +-
 remote.c                   |  49 ++++++------
 t/t0040-parse-options.sh   |   4 +-
 t/t1410-reflog.sh          |   6 +-
 t/t1450-fsck.sh            |  52 ++++++-------
 t/t4211-line-log.sh        |   2 +-
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +-
 21 files changed, 292 insertions(+), 259 deletions(-)

-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 01/16] git.c: mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:02     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
                     ` (15 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

One string is slightly updated to keep consistency with the rest:
die() should with lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/git.c b/git.c
index adac132956..5fd30da093 100644
--- a/git.c
+++ b/git.c
@@ -338,27 +338,27 @@ static int handle_alias(int *argcp, const char ***argv)
 			if (ret >= 0)   /* normal exit */
 				exit(ret);
 
-			die_errno("while expanding alias '%s': '%s'",
-			    alias_command, alias_string + 1);
+			die_errno(_("while expanding alias '%s': '%s'"),
+				  alias_command, alias_string + 1);
 		}
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
-			die("Bad alias.%s string: %s", alias_command,
+			die(_("bad alias.%s string: %s"), alias_command,
 			    split_cmdline_strerror(count));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
-			die("alias '%s' changes environment variables.\n"
-				 "You can use '!git' in the alias to do this",
-				 alias_command);
+			die(_("alias '%s' changes environment variables.\n"
+			      "You can use '!git' in the alias to do this"),
+			    alias_command);
 		memmove(new_argv - option_count, new_argv,
 				count * sizeof(char *));
 		new_argv -= option_count;
 
 		if (count < 1)
-			die("empty alias for %s", alias_command);
+			die(_("empty alias for %s"), alias_command);
 
 		if (!strcmp(alias_command, new_argv[0]))
-			die("recursive alias: %s", alias_command);
+			die(_("recursive alias: %s"), alias_command);
 
 		trace_argv_printf(new_argv,
 				  "trace: alias expansion: %s =>",
@@ -409,7 +409,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	if (!help && get_super_prefix()) {
 		if (!(p->option & SUPPORT_SUPER_PREFIX))
-			die("%s doesn't support --super-prefix", p->cmd);
+			die(_("%s doesn't support --super-prefix"), p->cmd);
 	}
 
 	if (!help && p->option & NEED_WORK_TREE)
@@ -433,11 +433,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	/* Check for ENOSPC and EIO errors.. */
 	if (fflush(stdout))
-		die_errno("write failure on standard output");
+		die_errno(_("write failure on standard output"));
 	if (ferror(stdout))
-		die("unknown write failure on standard output");
+		die(_("unknown write failure on standard output"));
 	if (fclose(stdout))
-		die_errno("close failed on standard output");
+		die_errno(_("close failed on standard output"));
 	return 0;
 }
 
@@ -648,7 +648,7 @@ static void execv_dashed_external(const char **argv)
 	int status;
 
 	if (get_super_prefix())
-		die("%s doesn't support --super-prefix", argv[0]);
+		die(_("%s doesn't support --super-prefix"), argv[0]);
 
 	if (use_pager == -1 && !is_builtin(argv[0]))
 		use_pager = check_pager_config(argv[0]);
@@ -760,7 +760,7 @@ int cmd_main(int argc, const char **argv)
 	if (skip_prefix(cmd, "git-", &cmd)) {
 		argv[0] = cmd;
 		handle_builtin(argc, argv);
-		die("cannot handle %s as a builtin", cmd);
+		die(_("cannot handle %s as a builtin"), cmd);
 	}
 
 	/* Look for flags.. */
@@ -773,7 +773,7 @@ int cmd_main(int argc, const char **argv)
 	} else {
 		/* The user didn't specify a command; give them help */
 		commit_pager_choice();
-		printf("usage: %s\n\n", git_usage_string);
+		printf(_("usage: %s\n\n"), git_usage_string);
 		list_common_cmds_help();
 		printf("\n%s\n", _(git_more_info_string));
 		exit(1);
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 02/16] alias.c: mark split_cmdline_strerror() strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
                     ` (14 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

This function can be part of translated messages. To make sure we
don't have a sentence with mixed languages, mark the strings for
translation, but only use translated strings in places we know we will
output translated strings.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 alias.c         | 4 ++--
 builtin/merge.c | 2 +-
 git.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/alias.c b/alias.c
index a7e4e57130..c471538020 100644
--- a/alias.c
+++ b/alias.c
@@ -47,8 +47,8 @@ void list_aliases(struct string_list *list)
 #define SPLIT_CMDLINE_BAD_ENDING 1
 #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
 static const char *split_cmdline_errors[] = {
-	"cmdline ends with \\",
-	"unclosed quote"
+	N_("cmdline ends with \\"),
+	N_("unclosed quote")
 };
 
 int split_cmdline(char *cmdline, const char ***argv)
diff --git a/builtin/merge.c b/builtin/merge.c
index 4aa6071598..92ba7e1c6d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -577,7 +577,7 @@ static void parse_branch_merge_options(char *bmo)
 	argc = split_cmdline(bmo, &argv);
 	if (argc < 0)
 		die(_("Bad branch.%s.mergeoptions string: %s"), branch,
-		    split_cmdline_strerror(argc));
+		    _(split_cmdline_strerror(argc)));
 	REALLOC_ARRAY(argv, argc + 2);
 	MOVE_ARRAY(argv + 1, argv, argc + 1);
 	argc++;
diff --git a/git.c b/git.c
index 5fd30da093..c7e122cfc1 100644
--- a/git.c
+++ b/git.c
@@ -344,7 +344,7 @@ static int handle_alias(int *argcp, const char ***argv)
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
 			die(_("bad alias.%s string: %s"), alias_command,
-			    split_cmdline_strerror(count));
+			    _(split_cmdline_strerror(count)));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
 			die(_("alias '%s' changes environment variables.\n"
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 03/16] archive.c: mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:09     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
                     ` (13 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

Two messages also print extra information to be more useful

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 archive.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/archive.c b/archive.c
index 9d16b7fadf..d8f6e1ce30 100644
--- a/archive.c
+++ b/archive.c
@@ -385,12 +385,12 @@ static void parse_treeish_arg(const char **argv,
 		int refnamelen = colon - name;
 
 		if (!dwim_ref(name, refnamelen, &oid, &ref))
-			die("no such ref: %.*s", refnamelen, name);
+			die(_("no such ref: %.*s"), refnamelen, name);
 		free(ref);
 	}
 
 	if (get_oid(name, &oid))
-		die("Not a valid object name");
+		die(_("not a valid object name: %s"), name);
 
 	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
 	if (commit) {
@@ -403,7 +403,7 @@ static void parse_treeish_arg(const char **argv,
 
 	tree = parse_tree_indirect(&oid);
 	if (tree == NULL)
-		die("not a tree object");
+		die(_("not a tree object: %s"), oid_to_hex(&oid));
 
 	if (prefix) {
 		struct object_id tree_oid;
@@ -413,7 +413,7 @@ static void parse_treeish_arg(const char **argv,
 		err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
 				     &mode);
 		if (err || !S_ISDIR(mode))
-			die("current working directory is untracked");
+			die(_("current working directory is untracked"));
 
 		tree = parse_tree_indirect(&tree_oid);
 	}
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 04/16] attr.c: mark more string for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (2 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
                     ` (12 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/attr.c b/attr.c
index 60d284796d..3770bc1a11 100644
--- a/attr.c
+++ b/attr.c
@@ -372,8 +372,8 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
 	if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
 	    starts_with(name, ATTRIBUTE_MACRO_PREFIX)) {
 		if (!macro_ok) {
-			fprintf(stderr, "%s not allowed: %s:%d\n",
-				name, src, lineno);
+			fprintf_ln(stderr, _("%s not allowed: %s:%d"),
+				   name, src, lineno);
 			goto fail_return;
 		}
 		is_macro = 1;
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG()
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (3 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:10     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
                     ` (11 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index d57958233e..0c37f4885e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -316,7 +316,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
 			changed |= DATA_CHANGED;
 		return changed;
 	default:
-		die("internal error: ce_mode is %o", ce->ce_mode);
+		BUG("unsupported ce_mode: %o", ce->ce_mode);
 	}
 
 	changed |= match_stat_data(&ce->ce_stat_data, st);
@@ -2356,14 +2356,14 @@ void validate_cache_entries(const struct index_state *istate)
 
 	for (i = 0; i < istate->cache_nr; i++) {
 		if (!istate) {
-			die("internal error: cache entry is not allocated from expected memory pool");
+			BUG("cache entry is not allocated from expected memory pool");
 		} else if (!istate->ce_mem_pool ||
 			!mem_pool_contains(istate->ce_mem_pool, istate->cache[i])) {
 			if (!istate->split_index ||
 				!istate->split_index->base ||
 				!istate->split_index->base->ce_mem_pool ||
 				!mem_pool_contains(istate->split_index->base->ce_mem_pool, istate->cache[i])) {
-				die("internal error: cache entry is not allocated from expected memory pool");
+				BUG("cache entry is not allocated from expected memory pool");
 			}
 		}
 	}
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 06/16] read-cache.c: mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (4 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
                     ` (10 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

There are a couple other improvements on these strings as well:

 - add missing colon (as separator)
 - quote paths
 - provide more information on error messages
 - keep first word in lowercase

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c    | 57 +++++++++++++++++++++++++------------------------
 t/t1450-fsck.sh |  2 +-
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 0c37f4885e..858befe738 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -672,7 +672,8 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
 	struct cache_entry *new_entry;
 
 	if (alias->ce_flags & CE_ADDED)
-		die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+		die(_("will not add file alias '%s' ('%s' already exists in index)"),
+		    ce->name, alias->name);
 
 	/* Ok, create the new entry using the name of the existing alias */
 	len = ce_namelen(alias);
@@ -687,7 +688,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
 {
 	struct object_id oid;
 	if (write_object_file("", 0, blob_type, &oid))
-		die("cannot create an empty blob in the object database");
+		die(_("cannot create an empty blob in the object database"));
 	oidcpy(&ce->oid, &oid);
 }
 
@@ -708,7 +709,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		newflags |= HASH_RENORMALIZE;
 
 	if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
-		return error("%s: can only add regular files, symbolic links or git-directories", path);
+		return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
 
 	namelen = strlen(path);
 	if (S_ISDIR(st_mode)) {
@@ -763,7 +764,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 	if (!intent_only) {
 		if (index_path(istate, &ce->oid, path, st, newflags)) {
 			discard_cache_entry(ce);
-			return error("unable to index file %s", path);
+			return error(_("unable to index file '%s'"), path);
 		}
 	} else
 		set_object_name_for_intent_to_add_entry(ce);
@@ -782,7 +783,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		discard_cache_entry(ce);
 	else if (add_index_entry(istate, ce, add_option)) {
 		discard_cache_entry(ce);
-		return error("unable to add %s to index", path);
+		return error(_("unable to add '%s' to index"), path);
 	}
 	if (verbose && !was_same)
 		printf("add '%s'\n", path);
@@ -793,7 +794,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
 {
 	struct stat st;
 	if (lstat(path, &st))
-		die_errno("unable to stat '%s'", path);
+		die_errno(_("unable to stat '%s'"), path);
 	return add_to_index(istate, path, &st, flags);
 }
 
@@ -818,7 +819,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -844,7 +845,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -1297,12 +1298,12 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
 	if (!ok_to_add)
 		return -1;
 	if (!verify_path(ce->name, ce->ce_mode))
-		return error("Invalid path '%s'", ce->name);
+		return error(_("invalid path '%s'"), ce->name);
 
 	if (!skip_df_check &&
 	    check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
 		if (!ok_to_replace)
-			return error("'%s' appears as both a file and as a directory",
+			return error(_("'%s' appears as both a file and as a directory"),
 				     ce->name);
 		pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
 		pos = -pos-1;
@@ -1676,10 +1677,10 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	int hdr_version;
 
 	if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
-		return error("bad signature");
+		return error(_("bad signature 0x%08x"), hdr->hdr_signature);
 	hdr_version = ntohl(hdr->hdr_version);
 	if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
-		return error("bad index version %d", hdr_version);
+		return error(_("bad index version %d"), hdr_version);
 
 	if (!verify_index_checksum)
 		return 0;
@@ -1688,7 +1689,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
 	the_hash_algo->final_fn(hash, &c);
 	if (!hasheq(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
-		return error("bad index file sha1 signature");
+		return error(_("bad index file sha1 signature"));
 	return 0;
 }
 
@@ -1718,9 +1719,9 @@ static int read_index_extension(struct index_state *istate,
 		break;
 	default:
 		if (*ext < 'A' || 'Z' < *ext)
-			return error("index uses %.4s extension, which we do not understand",
+			return error(_("index uses %.4s extension, which we do not understand"),
 				     ext);
-		fprintf(stderr, "ignoring %.4s extension\n", ext);
+		fprintf_ln(stderr, _("ignoring %.4s extension"), ext);
 		break;
 	}
 	return 0;
@@ -1767,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
 		extended_flags = get_be16(&ondisk2->flags2) << 16;
 		/* We do not yet understand any bit out of CE_EXTENDED_FLAGS */
 		if (extended_flags & ~CE_EXTENDED_FLAGS)
-			die("Unknown index entry format %08x", extended_flags);
+			die(_("unknown index entry format 0x%08x"), extended_flags);
 		flags |= extended_flags;
 		name = ondisk2->name;
 	}
@@ -1840,13 +1841,13 @@ static void check_ce_order(struct index_state *istate)
 		int name_compare = strcmp(ce->name, next_ce->name);
 
 		if (0 < name_compare)
-			die("unordered stage entries in index");
+			die(_("unordered stage entries in index"));
 		if (!name_compare) {
 			if (!ce_stage(ce))
-				die("multiple stage entries for merged file '%s'",
+				die(_("multiple stage entries for merged file '%s'"),
 				    ce->name);
 			if (ce_stage(ce) > ce_stage(next_ce))
-				die("unordered stage entries for '%s'",
+				die(_("unordered stage entries for '%s'"),
 				    ce->name);
 		}
 	}
@@ -2149,19 +2150,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 	if (fd < 0) {
 		if (!must_exist && errno == ENOENT)
 			return 0;
-		die_errno("%s: index file open failed", path);
+		die_errno(_("%s: index file open failed"), path);
 	}
 
 	if (fstat(fd, &st))
-		die_errno("cannot stat the open index");
+		die_errno(_("%s: cannot stat the open index"), path);
 
 	mmap_size = xsize_t(st.st_size);
 	if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz)
-		die("index file smaller than expected");
+		die(_("%s: index file smaller than expected"), path);
 
 	mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	if (mmap == MAP_FAILED)
-		die_errno("unable to map index file");
+		die_errno(_("%s: unable to map index file"), path);
 	close(fd);
 
 	hdr = (const struct cache_header *)mmap;
@@ -2243,7 +2244,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 
 unmap:
 	munmap((void *)mmap, mmap_size);
-	die("index file corrupt");
+	die(_("index file corrupt"));
 }
 
 /*
@@ -2255,7 +2256,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 static void freshen_shared_index(const char *shared_index, int warn)
 {
 	if (!check_and_freshen_file(shared_index, 1) && warn)
-		warning("could not freshen shared index '%s'", shared_index);
+		warning(_("could not freshen shared index '%s'"), shared_index);
 }
 
 int read_index_from(struct index_state *istate, const char *path,
@@ -2290,7 +2291,7 @@ int read_index_from(struct index_state *istate, const char *path,
 	base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
 	ret = do_read_index(split_index->base, base_path, 1);
 	if (!oideq(&split_index->base_oid, &split_index->base->oid))
-		die("broken index, expect %s in %s, got %s",
+		die(_("broken index, expect %s in %s, got %s"),
 		    base_oid_hex, base_path,
 		    oid_to_hex(&split_index->base->oid));
 
@@ -3076,7 +3077,7 @@ static int write_shared_index(struct index_state *istate,
 		return ret;
 	ret = adjust_shared_perm(get_tempfile_path(*temp));
 	if (ret) {
-		error("cannot fix permission bits on %s", get_tempfile_path(*temp));
+		error(_("cannot fix permission bits on '%s'"), get_tempfile_path(*temp));
 		return ret;
 	}
 	ret = rename_tempfile(temp,
@@ -3222,7 +3223,7 @@ int read_index_unmerged(struct index_state *istate)
 		new_ce->ce_namelen = len;
 		new_ce->ce_mode = ce->ce_mode;
 		if (add_index_entry(istate, new_ce, ADD_CACHE_SKIP_DFCHECK))
-			return error("%s: cannot drop to stage #0",
+			return error(_("%s: cannot drop to stage #0"),
 				     new_ce->name);
 	}
 	return unmerged;
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 0f2dd26f74..90c765df3a 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -754,7 +754,7 @@ test_expect_success 'detect corrupt index file in fsck' '
 	test_when_finished "mv .git/index.backup .git/index" &&
 	corrupt_index_checksum &&
 	test_must_fail git fsck --cache 2>errors &&
-	grep "bad index file" errors
+	test_i18ngrep "bad index file" errors
 '
 
 test_done
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 07/16] read-cache.c: add missing colon separators
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (5 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:12     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
                     ` (9 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

typechange_fmt and added_fmt should have a colon before "needs
update". Align the statements to make it easier to read and see. Also
drop the unnecessary ().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 858befe738..8d99ae376c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1492,11 +1492,11 @@ int refresh_index(struct index_state *istate, unsigned int flags,
 						  istate->cache_nr);
 
 	trace_performance_enter();
-	modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
-	deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
-	typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
-	added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
-	unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+	modified_fmt   = in_porcelain ? "M\t%s\n" : "%s: needs update\n";
+	deleted_fmt    = in_porcelain ? "D\t%s\n" : "%s: needs update\n";
+	typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n";
+	added_fmt      = in_porcelain ? "A\t%s\n" : "%s: needs update\n";
+	unmerged_fmt   = in_porcelain ? "U\t%s\n" : "%s: needs merge\n";
 	for (i = 0; i < istate->cache_nr; i++) {
 		struct cache_entry *ce, *new_entry;
 		int cache_errno = 0;
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 08/16] reflog: mark strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (6 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:13     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
                     ` (8 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

One string "nothing to delete?" is rephrased to be more helpful.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/reflog.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index b5941c1ff3..5a74ccf7ab 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -13,11 +13,15 @@
 
 /* NEEDSWORK: switch to using parse_options */
 static const char reflog_expire_usage[] =
-"git reflog expire [--expire=<time>] [--expire-unreachable=<time>] [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] <refs>...";
+N_("git reflog expire [--expire=<time>] "
+   "[--expire-unreachable=<time>] "
+   "[--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] "
+   "[--verbose] [--all] <refs>...");
 static const char reflog_delete_usage[] =
-"git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] <refs>...";
+N_("git reflog delete [--rewrite] [--updateref] "
+   "[--dry-run | -n] [--verbose] <refs>...");
 static const char reflog_exists_usage[] =
-"git reflog exists <ref>";
+N_("git reflog exists <ref>");
 
 static timestamp_t default_reflog_expire;
 static timestamp_t default_reflog_expire_unreachable;
@@ -556,7 +560,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_expire_usage);
+			usage(_(reflog_expire_usage));
 		else
 			break;
 	}
@@ -569,7 +573,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 	if (cb.cmd.stalefix) {
 		repo_init_revisions(the_repository, &cb.cmd.revs, prefix);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
-			printf("Marking reachable objects...");
+			printf(_("Marking reachable objects..."));
 		mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
 			putchar('\n');
@@ -598,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 		char *ref;
 		struct object_id oid;
 		if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {
-			status |= error("%s points nowhere!", argv[i]);
+			status |= error(_("%s points nowhere!"), argv[i]);
 			continue;
 		}
 		set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
@@ -644,13 +648,13 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_delete_usage);
+			usage(_(reflog_delete_usage));
 		else
 			break;
 	}
 
 	if (argc - i < 1)
-		return error("Nothing to delete?");
+		return error(_("no reflog specified to delete"));
 
 	for ( ; i < argc; i++) {
 		const char *spec = strstr(argv[i], "@{");
@@ -659,12 +663,12 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 		int recno;
 
 		if (!spec) {
-			status |= error("Not a reflog: %s", argv[i]);
+			status |= error(_("not a reflog: %s"), argv[i]);
 			continue;
 		}
 
 		if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
-			status |= error("no reflog for '%s'", argv[i]);
+			status |= error(_("no reflog for '%s'"), argv[i]);
 			continue;
 		}
 
@@ -699,7 +703,7 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_exists_usage);
+			usage(_(reflog_exists_usage));
 		else
 			break;
 	}
@@ -707,10 +711,10 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 	start = i;
 
 	if (argc - start != 1)
-		usage(reflog_exists_usage);
+		usage(_(reflog_exists_usage));
 
 	if (check_refname_format(argv[start], REFNAME_ALLOW_ONELEVEL))
-		die("invalid ref format: %s", argv[start]);
+		die(_("invalid ref format: %s"), argv[start]);
 	return !reflog_exists(argv[start]);
 }
 
@@ -719,12 +723,12 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
  */
 
 static const char reflog_usage[] =
-"git reflog [ show | expire | delete | exists ]";
+N_("git reflog [ show | expire | delete | exists ]");
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
 	if (argc > 1 && !strcmp(argv[1], "-h"))
-		usage(reflog_usage);
+		usage(_(reflog_usage));
 
 	/* With no command, we default to showing it. */
 	if (argc < 2 || *argv[1] == '-')
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 09/16] remote.c: turn some error() or die() to BUG()
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (7 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:21     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
                     ` (7 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

The first error, "internal error", is clearly a BUG(). The second two
are meant to catch calls with invalid parameters and should never
happen outside the test suite.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index 81f4f01b00..257630ff21 100644
--- a/remote.c
+++ b/remote.c
@@ -620,7 +620,7 @@ static void handle_duplicate(struct ref *ref1, struct ref *ref2)
 			 * FETCH_HEAD_IGNORE entries always appear at
 			 * the end of the list.
 			 */
-			die(_("Internal error"));
+			BUG("Internal error");
 		}
 	}
 	free(ref2->peer_ref);
@@ -707,7 +707,7 @@ static void query_refspecs_multiple(struct refspec *rs,
 	int find_src = !query->src;
 
 	if (find_src && !query->dst)
-		error("query_refspecs_multiple: need either src or dst");
+		BUG("query_refspecs_multiple: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
@@ -735,7 +735,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
 	char **result = find_src ? &query->src : &query->dst;
 
 	if (find_src && !query->dst)
-		return error("query_refspecs: need either src or dst");
+		BUG("query_refspecs: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 10/16] remote.c: mark messages for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (8 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
                     ` (6 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

The two strings are slightly modified to be consistent with the rest:
die() and error() start with a lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/remote.c b/remote.c
index 257630ff21..11b33d1625 100644
--- a/remote.c
+++ b/remote.c
@@ -359,7 +359,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		return 0;
 	/* Handle remote.<name>.* variables */
 	if (*name == '/') {
-		warning("Config remote shorthand cannot begin with '/': %s",
+		warning(_("config remote shorthand cannot begin with '/': %s"),
 			name);
 		return 0;
 	}
@@ -406,7 +406,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->receivepack)
 			remote->receivepack = v;
 		else
-			error("more than one receivepack given, using the first");
+			error(_("more than one receivepack given, using the first"));
 	} else if (!strcmp(subkey, "uploadpack")) {
 		const char *v;
 		if (git_config_string(&v, key, value))
@@ -414,7 +414,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->uploadpack)
 			remote->uploadpack = v;
 		else
-			error("more than one uploadpack given, using the first");
+			error(_("more than one uploadpack given, using the first"));
 	} else if (!strcmp(subkey, "tagopt")) {
 		if (!strcmp(value, "--no-tags"))
 			remote->fetch_tags = -1;
@@ -680,7 +680,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 	size_t namelen;
 	int ret;
 	if (!kstar)
-		die("Key '%s' of pattern had no '*'", key);
+		die(_("key '%s' of pattern had no '*'"), key);
 	klen = kstar - key;
 	ksuffixlen = strlen(kstar + 1);
 	namelen = strlen(name);
@@ -690,7 +690,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 		struct strbuf sb = STRBUF_INIT;
 		const char *vstar = strchr(value, '*');
 		if (!vstar)
-			die("Value '%s' of pattern has no '*'", value);
+			die(_("value '%s' of pattern has no '*'"), value);
 		strbuf_add(&sb, value, vstar - value);
 		strbuf_add(&sb, name + klen, namelen - klen - ksuffixlen);
 		strbuf_addstr(&sb, vstar + 1);
@@ -995,12 +995,12 @@ static int match_explicit_lhs(struct ref *src,
 		 * way to delete 'other' ref at the remote end.
 		 */
 		if (try_explicit_object_name(rs->src, match) < 0)
-			return error("src refspec %s does not match any.", rs->src);
+			return error(_("src refspec %s does not match any"), rs->src);
 		if (allocated_match)
 			*allocated_match = 1;
 		return 0;
 	default:
-		return error("src refspec %s matches more than one.", rs->src);
+		return error(_("src refspec %s matches more than one"), rs->src);
 	}
 }
 
@@ -1030,7 +1030,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (!dst_value ||
 		    ((flag & REF_ISSYMREF) &&
 		     !starts_with(dst_value, "refs/heads/")))
-			die("%s cannot be resolved to branch.",
+			die(_("%s cannot be resolved to branch"),
 			    matched_src->name);
 	}
 
@@ -1041,30 +1041,30 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (starts_with(dst_value, "refs/"))
 			matched_dst = make_linked_ref(dst_value, dst_tail);
 		else if (is_null_oid(&matched_src->new_oid))
-			error("unable to delete '%s': remote ref does not exist",
+			error(_("unable to delete '%s': remote ref does not exist"),
 			      dst_value);
 		else if ((dst_guess = guess_ref(dst_value, matched_src))) {
 			matched_dst = make_linked_ref(dst_guess, dst_tail);
 			free(dst_guess);
 		} else
-			error("unable to push to unqualified destination: %s\n"
-			      "The destination refspec neither matches an "
-			      "existing ref on the remote nor\n"
-			      "begins with refs/, and we are unable to "
-			      "guess a prefix based on the source ref.",
+			error(_("unable to push to unqualified destination: %s\n"
+				"The destination refspec neither matches an "
+				"existing ref on the remote nor\n"
+				"begins with refs/, and we are unable to "
+				"guess a prefix based on the source ref."),
 			      dst_value);
 		break;
 	default:
 		matched_dst = NULL;
-		error("dst refspec %s matches more than one.",
+		error(_("dst refspec %s matches more than one"),
 		      dst_value);
 		break;
 	}
 	if (!matched_dst)
 		return -1;
 	if (matched_dst->peer_ref)
-		return error("dst ref %s receives from more than one src.",
-		      matched_dst->name);
+		return error(_("dst ref %s receives from more than one src"),
+			     matched_dst->name);
 	else {
 		matched_dst->peer_ref = allocated_src ?
 					matched_src :
@@ -1750,7 +1750,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			ref_map = get_remote_ref(remote_refs, name);
 		}
 		if (!missing_ok && !ref_map)
-			die("Couldn't find remote ref %s", name);
+			die(_("couldn't find remote ref %s"), name);
 		if (ref_map) {
 			ref_map->peer_ref = get_local_ref(refspec->dst);
 			if (ref_map->peer_ref && refspec->force)
@@ -1763,7 +1763,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			if (!starts_with((*rmp)->peer_ref->name, "refs/") ||
 			    check_refname_format((*rmp)->peer_ref->name, 0)) {
 				struct ref *ignore = *rmp;
-				error("* Ignoring funny ref '%s' locally",
+				error(_("* Ignoring funny ref '%s' locally"),
 				      (*rmp)->peer_ref->name);
 				*rmp = (*rmp)->next;
 				free(ignore->peer_ref);
@@ -1858,7 +1858,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
 	repo_init_revisions(the_repository, &revs, NULL);
 	setup_revisions(argv.argc, argv.argv, &revs, NULL);
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	/* ... and count the commits on each side. */
 	while (1) {
@@ -2131,7 +2131,8 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
 	else if (!colon[1])
 		oidclr(&entry->expect);
 	else if (get_oid(colon + 1, &entry->expect))
-		return error("cannot parse expected object name '%s'", colon + 1);
+		return error(_("cannot parse expected object name '%s'"),
+			     colon + 1);
 	return 0;
 }
 
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 11/16] repack: mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (9 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
                     ` (5 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

Two strings are slightly updated to be consistent with the rest: die()
starts with lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/repack.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/builtin/repack.c b/builtin/repack.c
index c6a7943d5c..0af20fa0fc 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -197,7 +197,7 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack,
 
 	if (cmd->in == -1) {
 		if (start_command(cmd))
-			die("Could not start pack-objects to repack promisor objects");
+			die(_("could not start pack-objects to repack promisor objects"));
 	}
 
 	xwrite(cmd->in, oid_to_hex(oid), GIT_SHA1_HEXSZ);
@@ -236,7 +236,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 		char *promisor_name;
 		int fd;
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects."));
 		string_list_append(names, line.buf);
 
 		/*
@@ -247,13 +247,13 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 					  line.buf);
 		fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
 		if (fd < 0)
-			die_errno("unable to create '%s'", promisor_name);
+			die_errno(_("unable to create '%s'"), promisor_name);
 		close(fd);
 		free(promisor_name);
 	}
 	fclose(out);
 	if (finish_command(&cmd))
-		die("Could not finish pack-objects to repack promisor objects");
+		die(_("could not finish pack-objects to repack promisor objects"));
 }
 
 #define ALL_INTO_ONE 1
@@ -408,7 +408,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	out = xfdopen(cmd.out, "r");
 	while (strbuf_getline_lf(&line, out) != EOF) {
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects"));
 		string_list_append(&names, line.buf);
 	}
 	fclose(out);
@@ -417,7 +417,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		return ret;
 
 	if (!names.nr && !po_args.quiet)
-		printf("Nothing new to pack.\n");
+		printf_ln(_("Nothing new to pack."));
 
 	/*
 	 * Ok we have prepared all new packfiles.
@@ -477,13 +477,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		if (rollback_failure.nr) {
 			int i;
 			fprintf(stderr,
-				"WARNING: Some packs in use have been renamed by\n"
-				"WARNING: prefixing old- to their name, in order to\n"
-				"WARNING: replace them with the new version of the\n"
-				"WARNING: file.  But the operation failed, and the\n"
-				"WARNING: attempt to rename them back to their\n"
-				"WARNING: original names also failed.\n"
-				"WARNING: Please rename them in %s manually:\n", packdir);
+				_("WARNING: Some packs in use have been renamed by\n"
+				  "WARNING: prefixing old- to their name, in order to\n"
+				  "WARNING: replace them with the new version of the\n"
+				  "WARNING: file.  But the operation failed, and the\n"
+				  "WARNING: attempt to rename them back to their\n"
+				  "WARNING: original names also failed.\n"
+				  "WARNING: Please rename them in %s manually:\n"), packdir);
 			for (i = 0; i < rollback_failure.nr; i++)
 				fprintf(stderr, "WARNING:   old-%s -> %s\n",
 					rollback_failure.items[i].string,
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (10 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  2:33     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
                     ` (4 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

There are a few issues with opterror()

- it tries to assemble an English sentence from pieces. This is not
  great for translators because we give them pieces instead of a full
  sentence.

- It's a wrapper around error() and needs some hack to let the
  compiler know it always returns -1.

- Since it takes a string instead of printf format, one call site has
  to assemble the string manually before passing to it.

Kill it and produce the option name with optname(). The user will use
error() directly. This solves the second and third problems.

It kind helps the first problem as well because "%s does foo" does
give a translator a full sentence in a sense and let them reorder if
needed. But it has limitations, if the subject part has to change
based on the rest of the sentence, that language is screwed. This is
also why I try to avoid calling optname() when 'flags' is known in
advance.

Mark of these strings for translation as well while at there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge.c     |  2 +-
 builtin/revert.c    |  3 ++-
 parse-options-cb.c  |  7 ++++---
 parse-options.c     | 46 +++++++++++++++++++++++++--------------------
 parse-options.h     |  5 +----
 ref-filter.c        |  8 +++++---
 t/t4211-line-log.sh |  2 +-
 7 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 92ba7e1c6d..82248d43c3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -128,7 +128,7 @@ static int option_read_message(struct parse_opt_ctx_t *ctx,
 		ctx->argc--;
 		arg = *++ctx->argv;
 	} else
-		return opterror(opt, "requires a value", 0);
+		return error(_("option `%s' requires a value"), opt->long_name);
 
 	if (buf->len)
 		strbuf_addch(buf, '\n');
diff --git a/builtin/revert.c b/builtin/revert.c
index c93393c89b..11190d2ab4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -69,7 +69,8 @@ static int option_parse_m(const struct option *opt,
 
 	replay->mainline = strtol(arg, &end, 10);
 	if (*end || replay->mainline <= 0)
-		return opterror(opt, "expects a number greater than zero", 0);
+		return error(_("option `%s' expects a number greater than zero"),
+			     opt->long_name);
 
 	return 0;
 }
diff --git a/parse-options-cb.c b/parse-options-cb.c
index e8236534ac..813eb6301b 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -18,7 +18,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
 	} else {
 		v = strtol(arg, (char **)&arg, 10);
 		if (*arg)
-			return opterror(opt, "expects a numerical value", 0);
+			return error(_("option `%s' expects a numerical value"),
+				     opt->long_name);
 		if (v && v < MINIMUM_ABBREV)
 			v = MINIMUM_ABBREV;
 		else if (v > 40)
@@ -54,8 +55,8 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
 		arg = unset ? "never" : (const char *)opt->defval;
 	value = git_config_colorbool(NULL, arg);
 	if (value < 0)
-		return opterror(opt,
-			"expects \"always\", \"auto\", or \"never\"", 0);
+		return error(_("option `%s' expects \"always\", \"auto\", or \"never\""),
+			     opt->long_name);
 	*(int *)opt->value = value;
 	return 0;
 }
diff --git a/parse-options.c b/parse-options.c
index 3b874a83a0..0bf817193d 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -32,7 +32,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
 		p->argc--;
 		*arg = *++p->argv;
 	} else
-		return opterror(opt, "requires a value", flags);
+		return error(_("%s requires a value"), optname(opt, flags));
 	return 0;
 }
 
@@ -49,7 +49,6 @@ static int opt_command_mode_error(const struct option *opt,
 				  int flags)
 {
 	const struct option *that;
-	struct strbuf message = STRBUF_INIT;
 	struct strbuf that_name = STRBUF_INIT;
 
 	/*
@@ -67,13 +66,13 @@ static int opt_command_mode_error(const struct option *opt,
 			strbuf_addf(&that_name, "--%s", that->long_name);
 		else
 			strbuf_addf(&that_name, "-%c", that->short_name);
-		strbuf_addf(&message, ": incompatible with %s", that_name.buf);
+		error(_("%s is incompatible with %s"),
+		      optname(opt, flags), that_name.buf);
 		strbuf_release(&that_name);
-		opterror(opt, message.buf, flags);
-		strbuf_release(&message);
 		return -1;
 	}
-	return opterror(opt, ": incompatible with something else", flags);
+	return error(_("%s : incompatible with something else"),
+		     optname(opt, flags));
 }
 
 static int get_value(struct parse_opt_ctx_t *p,
@@ -86,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p,
 	int err;
 
 	if (unset && p->opt)
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 	if (unset && (opt->flags & PARSE_OPT_NONEG))
-		return opterror(opt, "isn't available", flags);
+		return error(_("%s isn't available"), optname(opt, flags));
 	if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 
 	switch (opt->type) {
 	case OPTION_LOWLEVEL_CALLBACK:
@@ -176,7 +175,8 @@ static int get_value(struct parse_opt_ctx_t *p,
 			return -1;
 		*(int *)opt->value = strtol(arg, (char **)&s, 10);
 		if (*s)
-			return opterror(opt, "expects a numerical value", flags);
+			return error(_("%s expects a numerical value"),
+				     optname(opt, flags));
 		return 0;
 
 	case OPTION_MAGNITUDE:
@@ -191,9 +191,9 @@ static int get_value(struct parse_opt_ctx_t *p,
 		if (get_arg(p, opt, flags, &arg))
 			return -1;
 		if (!git_parse_ulong(arg, opt->value))
-			return opterror(opt,
-				"expects a non-negative integer value with an optional k/m/g suffix",
-				flags);
+			return error(_("%s expects a non-negative integer value"
+				       " with an optional k/m/g suffix"),
+				     optname(opt, flags));
 		return 0;
 
 	default:
@@ -257,7 +257,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 			if (!rest)
 				continue;
 			if (*rest == '=')
-				return opterror(options, "takes no value", flags);
+				return error(_("%s takes no value"),
+					     optname(options, flags));
 			if (*rest)
 				continue;
 			p->out[p->cpidx++] = arg - 2;
@@ -773,12 +774,17 @@ void NORETURN usage_msg_opt(const char *msg,
 	usage_with_options(usagestr, options);
 }
 
-#undef opterror
-int opterror(const struct option *opt, const char *reason, int flags)
+const char *optname(const struct option *opt, int flags)
 {
+	static struct strbuf sb = STRBUF_INIT;
+
+	strbuf_reset(&sb);
 	if (flags & OPT_SHORT)
-		return error("switch `%c' %s", opt->short_name, reason);
-	if (flags & OPT_UNSET)
-		return error("option `no-%s' %s", opt->long_name, reason);
-	return error("option `%s' %s", opt->long_name, reason);
+		strbuf_addf(&sb, "switch `%c'", opt->short_name);
+	else if (flags & OPT_UNSET)
+		strbuf_addf(&sb, "option `no-%s'", opt->long_name);
+	else
+		strbuf_addf(&sb, "option `%s'", opt->long_name);
+
+	return sb.buf;
 }
diff --git a/parse-options.h b/parse-options.h
index dd14911a29..2e146aa6fa 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -189,10 +189,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
 				   const struct option *options);
 
 extern int optbug(const struct option *opt, const char *reason);
-extern int opterror(const struct option *opt, const char *reason, int flags);
-#if defined(__GNUC__)
-#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
-#endif
+const char *optname(const struct option *opt, int flags);
 
 /*----- incremental advanced APIs -----*/
 
diff --git a/ref-filter.c b/ref-filter.c
index 2a05619211..0681359100 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2302,9 +2302,11 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 
 	if (rf->merge) {
 		if (no_merged) {
-			return opterror(opt, "is incompatible with --merged", 0);
+			return error(_("option `%s' is incompatible with --merged"),
+				     opt->long_name);
 		} else {
-			return opterror(opt, "is incompatible with --no-merged", 0);
+			return error(_("option `%s' is incompatible with --no-merged"),
+				     opt->long_name);
 		}
 	}
 
@@ -2318,7 +2320,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 	rf->merge_commit = lookup_commit_reference_gently(the_repository,
 							  &oid, 0);
 	if (!rf->merge_commit)
-		return opterror(opt, "must point to a commit", 0);
+		return error(_("option `%s' must point to a commit"), opt->long_name);
 
 	return 0;
 }
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
index ef1322148e..bd5fe4d148 100755
--- a/t/t4211-line-log.sh
+++ b/t/t4211-line-log.sh
@@ -25,7 +25,7 @@ canned_test_failure () {
 test_bad_opts () {
 	test_expect_success "invalid args: $1" "
 		test_must_fail git log $1 2>errors &&
-		grep '$2' errors
+		test_i18ngrep '$2' errors
 	"
 }
 
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 13/16] parse-options.c: turn some die() to BUG()
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (11 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  3:27     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
                     ` (3 subsequent siblings)
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

These two strings are clearly not for the user to see. Reduce the
violence in one string while at there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 0bf817193d..3f5f985c1e 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -197,7 +197,7 @@ static int get_value(struct parse_opt_ctx_t *p,
 		return 0;
 
 	default:
-		die("should not happen, someone must be hit on the forehead");
+		BUG("opt->type %d should not happen", opt->type);
 	}
 }
 
@@ -424,7 +424,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
 	ctx->flags = flags;
 	if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
 	    (flags & PARSE_OPT_STOP_AT_NON_OPTION))
-		die("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
+		BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
 	parse_options_check(options);
 }
 
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 14/16] parse-options.c: mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (12 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-05 19:20   ` [PATCH v2 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
                     ` (2 subsequent siblings)
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

One error is updated to start with lowercase to be consistent with the
rest.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c          | 14 +++++++-------
 t/t0040-parse-options.sh |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 3f5f985c1e..86aad2e185 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -319,8 +319,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 	}
 
 	if (ambiguous_option) {
-		error("Ambiguous option: %s "
-			"(could be --%s%s or --%s%s)",
+		error(_("ambiguous option: %s "
+			"(could be --%s%s or --%s%s)"),
 			arg,
 			(ambiguous_flags & OPT_UNSET) ?  "no-" : "",
 			ambiguous_option->long_name,
@@ -353,7 +353,7 @@ static void check_typos(const char *arg, const struct option *options)
 		return;
 
 	if (starts_with(arg, "no-")) {
-		error ("did you mean `--%s` (with two dashes ?)", arg);
+		error(_("did you mean `--%s` (with two dashes ?)"), arg);
 		exit(129);
 	}
 
@@ -361,7 +361,7 @@ static void check_typos(const char *arg, const struct option *options)
 		if (!options->long_name)
 			continue;
 		if (starts_with(options->long_name, arg)) {
-			error ("did you mean `--%s` (with two dashes ?)", arg);
+			error(_("did you mean `--%s` (with two dashes ?)"), arg);
 			exit(129);
 		}
 	}
@@ -644,11 +644,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
 		break;
 	default: /* PARSE_OPT_UNKNOWN */
 		if (ctx.argv[0][1] == '-') {
-			error("unknown option `%s'", ctx.argv[0] + 2);
+			error(_("unknown option `%s'"), ctx.argv[0] + 2);
 		} else if (isascii(*ctx.opt)) {
-			error("unknown switch `%c'", *ctx.opt);
+			error(_("unknown switch `%c'"), *ctx.opt);
 		} else {
-			error("unknown non-ascii option in string: `%s'",
+			error(_("unknown non-ascii option in string: `%s'"),
 			      ctx.argv[0]);
 		}
 		usage_with_options(usagestr, options);
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 17d0c18feb..e46b1e02f0 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -228,7 +228,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -boolean >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 cat >typo.err <<\EOF
@@ -238,7 +238,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -ambiguous >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 test_expect_success 'keep some options as arguments' '
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 15/16] fsck: reduce word legos to help i18n
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (13 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-06  3:41     ` Junio C Hamano
  2018-11-05 19:20   ` [PATCH v2 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
  16 siblings, 1 reply; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

These messages will be marked for translation later. Reduce word legos
and give translators almost full phrases. describe_object() is updated
so that it can be called from printf() twice.

While at there, remove \n from the strings to reduce a bit of work
from translators.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c | 62 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 25 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 06eb421720..504f47d7a4 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -52,16 +52,24 @@ static int name_objects;
 
 static const char *describe_object(struct object *obj)
 {
-	static struct strbuf buf = STRBUF_INIT;
-	char *name = name_objects ?
-		lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
+	static struct strbuf bufs[4] = {
+		STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
+	};
+	static int b = 0;
+	struct strbuf *buf;
+	char *name = NULL;
 
-	strbuf_reset(&buf);
-	strbuf_addstr(&buf, oid_to_hex(&obj->oid));
+	if (name_objects)
+		name = lookup_decoration(fsck_walk_options.object_names, obj);
+
+	buf = bufs + b;
+	b = (b + 1) % ARRAY_SIZE(bufs);
+	strbuf_reset(buf);
+	strbuf_addstr(buf, oid_to_hex(&obj->oid));
 	if (name)
-		strbuf_addf(&buf, " (%s)", name);
+		strbuf_addf(buf, " (%s)", name);
 
-	return buf.buf;
+	return buf->buf;
 }
 
 static const char *printable_type(struct object *obj)
@@ -105,25 +113,26 @@ static int fsck_config(const char *var, const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }
 
-static void objreport(struct object *obj, const char *msg_type,
-			const char *err)
-{
-	fprintf(stderr, "%s in %s %s: %s\n",
-		msg_type, printable_type(obj), describe_object(obj), err);
-}
-
 static int objerror(struct object *obj, const char *err)
 {
 	errors_found |= ERROR_OBJECT;
-	objreport(obj, "error", err);
+	fprintf_ln(stderr, "error in %s %s: %s",
+		   printable_type(obj), describe_object(obj), err);
 	return -1;
 }
 
 static int fsck_error_func(struct fsck_options *o,
 	struct object *obj, int type, const char *message)
 {
-	objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
-	return (type == FSCK_WARN) ? 0 : 1;
+	if (type == FSCK_WARN) {
+		fprintf_ln(stderr, "warning in %s %s: %s",
+			   printable_type(obj), describe_object(obj), message);
+		return 0;
+	}
+
+	fprintf_ln(stderr, "error in %s %s: %s",
+		   printable_type(obj), describe_object(obj), message);
+	return 1;
 }
 
 static struct object_array pending;
@@ -165,10 +174,12 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
-			printf("broken link from %7s %s\n",
-				 printable_type(parent), describe_object(parent));
-			printf("              to %7s %s\n",
-				 printable_type(obj), describe_object(obj));
+			printf_ln("broken link from %7s %s\n"
+				  "              to %7s %s",
+				  printable_type(parent),
+				  describe_object(parent),
+				  printable_type(obj),
+				  describe_object(obj));
 			errors_found |= ERROR_REACHABLE;
 		}
 		return 1;
@@ -371,10 +382,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 		struct tag *tag = (struct tag *) obj;
 
 		if (show_tags && tag->tagged) {
-			printf("tagged %s %s", printable_type(tag->tagged),
-				describe_object(tag->tagged));
-			printf(" (%s) in %s\n", tag->tag,
-				describe_object(&tag->object));
+			printf_ln("tagged %s %s (%s) in %s",
+				  printable_type(tag->tagged),
+				  describe_object(tag->tagged),
+				  tag->tag,
+				  describe_object(&tag->object));
 		}
 	}
 
-- 
2.19.1.1005.gac84295441


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

* [PATCH v2 16/16] fsck: mark strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (14 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
@ 2018-11-05 19:20   ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
  16 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-05 19:20 UTC (permalink / raw)
  To: pclouds; +Cc: git, Junio C Hamano, SZEDER Gábor

Two die() are updated to start with lowercase to be consistent with
the rest.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c             | 106 ++++++++++++++++++++-----------------
 t/t1410-reflog.sh          |   6 +--
 t/t1450-fsck.sh            |  50 ++++++++---------
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +--
 5 files changed, 90 insertions(+), 82 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 504f47d7a4..0720708977 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -85,7 +85,7 @@ static const char *printable_type(struct object *obj)
 
 	ret = type_name(obj->type);
 	if (!ret)
-		ret = "unknown";
+		ret = _("unknown");
 
 	return ret;
 }
@@ -116,7 +116,8 @@ static int fsck_config(const char *var, const char *value, void *cb)
 static int objerror(struct object *obj, const char *err)
 {
 	errors_found |= ERROR_OBJECT;
-	fprintf_ln(stderr, "error in %s %s: %s",
+	/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
+	fprintf_ln(stderr, _("error in %s %s: %s"),
 		   printable_type(obj), describe_object(obj), err);
 	return -1;
 }
@@ -125,12 +126,14 @@ static int fsck_error_func(struct fsck_options *o,
 	struct object *obj, int type, const char *message)
 {
 	if (type == FSCK_WARN) {
-		fprintf_ln(stderr, "warning in %s %s: %s",
+		/* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
+		fprintf_ln(stderr, _("warning in %s %s: %s"),
 			   printable_type(obj), describe_object(obj), message);
 		return 0;
 	}
 
-	fprintf_ln(stderr, "error in %s %s: %s",
+	/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
+	fprintf_ln(stderr, _("error in %s %s: %s"),
 		   printable_type(obj), describe_object(obj), message);
 	return 1;
 }
@@ -148,17 +151,18 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 	 */
 	if (!obj) {
 		/* ... these references to parent->fld are safe here */
-		printf("broken link from %7s %s\n",
-			   printable_type(parent), describe_object(parent));
-		printf("broken link from %7s %s\n",
-			   (type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
+		printf_ln(_("broken link from %7s %s"),
+			  printable_type(parent), describe_object(parent));
+		printf_ln(_("broken link from %7s %s"),
+			  (type == OBJ_ANY ? _("unknown") : type_name(type)),
+			  _("unknown"));
 		errors_found |= ERROR_REACHABLE;
 		return 1;
 	}
 
 	if (type != OBJ_ANY && obj->type != type)
 		/* ... and the reference to parent is safe here */
-		objerror(parent, "wrong object type in link");
+		objerror(parent, _("wrong object type in link"));
 
 	if (obj->flags & REACHABLE)
 		return 0;
@@ -174,8 +178,8 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
-			printf_ln("broken link from %7s %s\n"
-				  "              to %7s %s",
+			printf_ln(_("broken link from %7s %s\n"
+				    "              to %7s %s"),
 				  printable_type(parent),
 				  describe_object(parent),
 				  printable_type(obj),
@@ -243,8 +247,8 @@ static void check_reachable_object(struct object *obj)
 			return;
 		if (has_object_pack(&obj->oid))
 			return; /* it is in pack - forget about it */
-		printf("missing %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("missing %s %s"), printable_type(obj),
+			  describe_object(obj));
 		errors_found |= ERROR_REACHABLE;
 		return;
 	}
@@ -269,8 +273,8 @@ static void check_unreachable_object(struct object *obj)
 	 * since this is something that is prunable.
 	 */
 	if (show_unreachable) {
-		printf("unreachable %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("unreachable %s %s"), printable_type(obj),
+			  describe_object(obj));
 		return;
 	}
 
@@ -288,8 +292,8 @@ static void check_unreachable_object(struct object *obj)
 	 */
 	if (!(obj->flags & USED)) {
 		if (show_dangling)
-			printf("dangling %s %s\n", printable_type(obj),
-			       describe_object(obj));
+			printf_ln(_("dangling %s %s"), printable_type(obj),
+				  describe_object(obj));
 		if (write_lost_and_found) {
 			char *filename = git_pathdup("lost-found/%s/%s",
 				obj->type == OBJ_COMMIT ? "commit" : "other",
@@ -297,18 +301,18 @@ static void check_unreachable_object(struct object *obj)
 			FILE *f;
 
 			if (safe_create_leading_directories_const(filename)) {
-				error("Could not create lost-found");
+				error(_("could not create lost-found"));
 				free(filename);
 				return;
 			}
 			f = xfopen(filename, "w");
 			if (obj->type == OBJ_BLOB) {
 				if (stream_blob_to_fd(fileno(f), &obj->oid, NULL, 1))
-					die_errno("Could not write '%s'", filename);
+					die_errno(_("could not write '%s'"), filename);
 			} else
 				fprintf(f, "%s\n", describe_object(obj));
 			if (fclose(f))
-				die_errno("Could not finish '%s'",
+				die_errno(_("could not finish '%s'"),
 					  filename);
 			free(filename);
 		}
@@ -325,7 +329,7 @@ static void check_unreachable_object(struct object *obj)
 static void check_object(struct object *obj)
 {
 	if (verbose)
-		fprintf(stderr, "Checking %s\n", describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s"), describe_object(obj));
 
 	if (obj->flags & REACHABLE)
 		check_reachable_object(obj);
@@ -343,7 +347,7 @@ static void check_connectivity(void)
 	/* Look up all the requirements, warn about missing objects.. */
 	max = get_max_object_index();
 	if (verbose)
-		fprintf(stderr, "Checking connectivity (%d objects)\n", max);
+		fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
 
 	for (i = 0; i < max; i++) {
 		struct object *obj = get_indexed_object(i);
@@ -362,11 +366,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 	obj->flags |= SEEN;
 
 	if (verbose)
-		fprintf(stderr, "Checking %s %s\n",
-			printable_type(obj), describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s %s"),
+			   printable_type(obj), describe_object(obj));
 
 	if (fsck_walk(obj, NULL, &fsck_obj_options))
-		objerror(obj, "broken links");
+		objerror(obj, _("broken links"));
 	err = fsck_object(obj, buffer, size, &fsck_obj_options);
 	if (err)
 		goto out;
@@ -375,14 +379,15 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 		struct commit *commit = (struct commit *) obj;
 
 		if (!commit->parents && show_root)
-			printf("root %s\n", describe_object(&commit->object));
+			printf_ln(_("root %s"),
+				  describe_object(&commit->object));
 	}
 
 	if (obj->type == OBJ_TAG) {
 		struct tag *tag = (struct tag *) obj;
 
 		if (show_tags && tag->tagged) {
-			printf_ln("tagged %s %s (%s) in %s",
+			printf_ln(_("tagged %s %s (%s) in %s"),
 				  printable_type(tag->tagged),
 				  describe_object(tag->tagged),
 				  tag->tag,
@@ -410,7 +415,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
 				  eaten);
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		return error("%s: object corrupt or missing", oid_to_hex(oid));
+		return error(_("%s: object corrupt or missing"),
+			     oid_to_hex(oid));
 	}
 	obj->flags &= ~(REACHABLE | SEEN);
 	obj->flags |= HAS_OBJ;
@@ -434,7 +440,8 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
 			obj->flags |= USED;
 			mark_object_reachable(obj);
 		} else if (!is_promisor_object(oid)) {
-			error("%s: invalid reflog entry %s", refname, oid_to_hex(oid));
+			error(_("%s: invalid reflog entry %s"),
+			      refname, oid_to_hex(oid));
 			errors_found |= ERROR_REACHABLE;
 		}
 	}
@@ -447,8 +454,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 	const char *refname = cb_data;
 
 	if (verbose)
-		fprintf(stderr, "Checking reflog %s->%s\n",
-			oid_to_hex(ooid), oid_to_hex(noid));
+		fprintf_ln(stderr, _("Checking reflog %s->%s"),
+			   oid_to_hex(ooid), oid_to_hex(noid));
 
 	fsck_handle_reflog_oid(refname, ooid, 0);
 	fsck_handle_reflog_oid(refname, noid, timestamp);
@@ -477,13 +484,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
 			 default_refs++;
 			 return 0;
 		}
-		error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
+		error(_("%s: invalid sha1 pointer %s"),
+		      refname, oid_to_hex(oid));
 		errors_found |= ERROR_REACHABLE;
 		/* We'll continue with the rest despite the error.. */
 		return 0;
 	}
 	if (obj->type != OBJ_COMMIT && is_branch(refname)) {
-		error("%s: not a commit", refname);
+		error(_("%s: not a commit"), refname);
 		errors_found |= ERROR_REFS;
 	}
 	default_refs++;
@@ -517,7 +525,7 @@ static void get_default_heads(void)
 	 * "show_unreachable" flag.
 	 */
 	if (!default_refs) {
-		fprintf(stderr, "notice: No default references\n");
+		fprintf_ln(stderr, _("notice: No default references"));
 		show_unreachable = 0;
 	}
 }
@@ -532,7 +540,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (read_loose_object(path, oid, &type, &size, &contents) < 0) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object corrupt or missing: %s",
+		error(_("%s: object corrupt or missing: %s"),
 		      oid_to_hex(oid), path);
 		return 0; /* keep checking other objects */
 	}
@@ -545,7 +553,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object could not be parsed: %s",
+		error(_("%s: object could not be parsed: %s"),
 		      oid_to_hex(oid), path);
 		if (!eaten)
 			free(contents);
@@ -565,7 +573,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 static int fsck_cruft(const char *basename, const char *path, void *data)
 {
 	if (!starts_with(basename, "tmp_obj_"))
-		fprintf(stderr, "bad sha1 file: %s\n", path);
+		fprintf_ln(stderr, _("bad sha1 file: %s"), path);
 	return 0;
 }
 
@@ -580,7 +588,7 @@ static void fsck_object_dir(const char *path)
 	struct progress *progress = NULL;
 
 	if (verbose)
-		fprintf(stderr, "Checking object directory\n");
+		fprintf_ln(stderr, _("Checking object directory"));
 
 	if (show_progress)
 		progress = start_progress(_("Checking object directories"), 256);
@@ -596,28 +604,28 @@ static int fsck_head_link(void)
 	int null_is_error = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking HEAD link\n");
+		fprintf_ln(stderr, _("Checking HEAD link"));
 
 	head_points_at = resolve_ref_unsafe("HEAD", 0, &head_oid, NULL);
 	if (!head_points_at) {
 		errors_found |= ERROR_REFS;
-		return error("Invalid HEAD");
+		return error(_("invalid HEAD"));
 	}
 	if (!strcmp(head_points_at, "HEAD"))
 		/* detached HEAD */
 		null_is_error = 1;
 	else if (!starts_with(head_points_at, "refs/heads/")) {
 		errors_found |= ERROR_REFS;
-		return error("HEAD points to something strange (%s)",
+		return error(_("HEAD points to something strange (%s)"),
 			     head_points_at);
 	}
 	if (is_null_oid(&head_oid)) {
 		if (null_is_error) {
 			errors_found |= ERROR_REFS;
-			return error("HEAD: detached HEAD points at nothing");
+			return error(_("HEAD: detached HEAD points at nothing"));
 		}
-		fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
-			head_points_at + 11);
+		fprintf_ln(stderr, _("notice: HEAD points to an unborn branch (%s)"),
+			   head_points_at + 11);
 	}
 	return 0;
 }
@@ -628,12 +636,12 @@ static int fsck_cache_tree(struct cache_tree *it)
 	int err = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking cache tree\n");
+		fprintf_ln(stderr, _("Checking cache tree"));
 
 	if (0 <= it->entry_count) {
 		struct object *obj = parse_object(the_repository, &it->oid);
 		if (!obj) {
-			error("%s: invalid sha1 pointer in cache-tree",
+			error(_("%s: invalid sha1 pointer in cache-tree"),
 			      oid_to_hex(&it->oid));
 			errors_found |= ERROR_REFS;
 			return 1;
@@ -644,7 +652,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 				obj, xstrdup(":"));
 		mark_object_reachable(obj);
 		if (obj->type != OBJ_TREE)
-			err |= objerror(obj, "non-tree in cache-tree");
+			err |= objerror(obj, _("non-tree in cache-tree"));
 	}
 	for (i = 0; i < it->subtree_nr; i++)
 		err |= fsck_cache_tree(it->down[i]->cache_tree);
@@ -786,7 +794,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			if (!obj || !(obj->flags & HAS_OBJ)) {
 				if (is_promisor_object(&oid))
 					continue;
-				error("%s: object missing", oid_to_hex(&oid));
+				error(_("%s: object missing"), oid_to_hex(&oid));
 				errors_found |= ERROR_OBJECT;
 				continue;
 			}
@@ -798,7 +806,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			mark_object_reachable(obj);
 			continue;
 		}
-		error("invalid parameter: expected sha1, got '%s'", arg);
+		error(_("invalid parameter: expected sha1, got '%s'"), arg);
 		errors_found |= ERROR_OBJECT;
 	}
 
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 388b0611d8..353bdfd415 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -20,12 +20,12 @@ check_have () {
 }
 
 check_fsck () {
-	output=$(git fsck --full)
+	git fsck --full >fsck.output
 	case "$1" in
 	'')
-		test -z "$output" ;;
+		test_must_be_empty fsck.output ;;
 	*)
-		echo "$output" | grep "$1" ;;
+		test_i18ngrep "$1" fsck.output ;;
 	esac
 }
 
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 90c765df3a..15ca98b2a9 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -70,7 +70,7 @@ test_expect_success 'object with bad sha1' '
 
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "$sha.*corrupt" out
+	test_i18ngrep "$sha.*corrupt" out
 '
 
 test_expect_success 'branch pointing to non-commit' '
@@ -78,7 +78,7 @@ test_expect_success 'branch pointing to non-commit' '
 	test_when_finished "git update-ref -d refs/heads/invalid" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "not a commit" out
+	test_i18ngrep "not a commit" out
 '
 
 test_expect_success 'HEAD link pointing at a funny object' '
@@ -88,7 +88,7 @@ test_expect_success 'HEAD link pointing at a funny object' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "detached HEAD points" out
+	test_i18ngrep "detached HEAD points" out
 '
 
 test_expect_success 'HEAD link pointing at a funny place' '
@@ -98,7 +98,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "HEAD points to something strange" out
+	test_i18ngrep "HEAD points to something strange" out
 '
 
 test_expect_success 'email without @ is okay' '
@@ -122,7 +122,7 @@ test_expect_success 'email with embedded > is not okay' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 test_expect_success 'missing < email delimiter is reported nicely' '
@@ -134,7 +134,7 @@ test_expect_success 'missing < email delimiter is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - bad name" out
+	test_i18ngrep "error in commit $new.* - bad name" out
 '
 
 test_expect_success 'missing email is reported nicely' '
@@ -146,7 +146,7 @@ test_expect_success 'missing email is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - missing email" out
+	test_i18ngrep "error in commit $new.* - missing email" out
 '
 
 test_expect_success '> in name is reported' '
@@ -158,7 +158,7 @@ test_expect_success '> in name is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 # date is 2^64 + 1
@@ -172,7 +172,7 @@ test_expect_success 'integer overflow in timestamps is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*integer overflow" out
+	test_i18ngrep "error in commit $new.*integer overflow" out
 '
 
 test_expect_success 'commit with NUL in header' '
@@ -184,7 +184,7 @@ test_expect_success 'commit with NUL in header' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'tree object with duplicate entries' '
@@ -205,7 +205,7 @@ test_expect_success 'tree object with duplicate entries' '
 		git hash-object -w -t tree --stdin
 	) &&
 	test_must_fail git fsck 2>out &&
-	grep "error in tree .*contains duplicate file entries" out
+	test_i18ngrep "error in tree .*contains duplicate file entries" out
 '
 
 test_expect_success 'unparseable tree object' '
@@ -259,7 +259,7 @@ test_expect_success 'tag pointing to nonexistent' '
 	test_when_finished "git update-ref -d refs/tags/invalid" &&
 	test_must_fail git fsck --tags >out &&
 	cat out &&
-	grep "broken link" out
+	test_i18ngrep "broken link" out
 '
 
 test_expect_success 'tag pointing to something else than its type' '
@@ -301,7 +301,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' '
 	warning in tag $tag: badTagName: invalid '\''tag'\'' name: wrong name format
 	warning in tag $tag: missingTaggerEntry: invalid format - expected '\''tagger'\'' line
 	EOF
-	test_cmp expect out
+	test_i18ncmp expect out
 '
 
 test_expect_success 'tag with bad tagger' '
@@ -320,7 +320,7 @@ test_expect_success 'tag with bad tagger' '
 	echo $tag >.git/refs/tags/wrong &&
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
-	grep "error in tag .*: invalid author/committer" out
+	test_i18ngrep "error in tag .*: invalid author/committer" out
 '
 
 test_expect_success 'tag with NUL in header' '
@@ -340,7 +340,7 @@ test_expect_success 'tag with NUL in header' '
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
 	cat out &&
-	grep "error in tag $tag.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'cleaned up' '
@@ -396,7 +396,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -407,7 +407,7 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -428,7 +428,7 @@ while read name path pretty; do
 			bad_tree=$(git mktree <bad) &&
 			git fsck 2>out &&
 			cat out &&
-			grep "warning.*tree $bad_tree" out
+			test_i18ngrep "warning.*tree $bad_tree" out
 		)'
 	done <<-\EOF
 	100644 blob
@@ -474,9 +474,9 @@ test_expect_success 'NUL in commit' '
 		git branch bad $(cat name) &&
 
 		test_must_fail git -c fsck.nulInCommit=error fsck 2>warn.1 &&
-		grep nulInCommit warn.1 &&
+		test_i18ngrep nulInCommit warn.1 &&
 		git fsck 2>warn.2 &&
-		grep nulInCommit warn.2
+		test_i18ngrep nulInCommit warn.2
 	)
 '
 
@@ -594,7 +594,7 @@ test_expect_success 'fsck --name-objects' '
 		remove_object $(git rev-parse julius:caesar.t) &&
 		test_must_fail git fsck --name-objects >out &&
 		tree=$(git rev-parse --verify julius:) &&
-		egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
+		test_i18ngrep -E "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
 	)
 '
 
@@ -605,7 +605,7 @@ test_expect_success 'alternate objects are correctly blamed' '
 	mkdir alt.git/objects/12 &&
 	>alt.git/objects/12/34567890123456789012345678901234567890 &&
 	test_must_fail git fsck >out 2>&1 &&
-	grep alt.git out
+	test_i18ngrep alt.git out
 '
 
 test_expect_success 'fsck errors in packed objects' '
@@ -624,8 +624,8 @@ test_expect_success 'fsck errors in packed objects' '
 	remove_object $one &&
 	remove_object $two &&
 	test_must_fail git fsck 2>out &&
-	grep "error in commit $one.* - bad name" out &&
-	grep "error in commit $two.* - bad name" out &&
+	test_i18ngrep "error in commit $one.* - bad name" out &&
+	test_i18ngrep "error in commit $two.* - bad name" out &&
 	! grep corrupt out
 '
 
@@ -706,7 +706,7 @@ test_expect_success 'fsck notices dangling objects' '
 		git fsck >actual &&
 		# the output order is non-deterministic, as it comes from a hash
 		sort <actual >actual.sorted &&
-		test_cmp expect actual.sorted
+		test_i18ncmp expect actual.sorted
 	)
 '
 
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 86374a9c52..7700a8e793 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -133,8 +133,8 @@ test_expect_success 'tag replaced commit' '
 
 test_expect_success '"git fsck" works' '
      git fsck master >fsck_master.out &&
-     grep "dangling commit $R" fsck_master.out &&
-     grep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
+     test_i18ngrep "dangling commit $R" fsck_master.out &&
+     test_i18ngrep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
      test -z "$(git fsck)"
 '
 
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index 293e2e1963..49a37efe9c 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -154,7 +154,7 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
 		# symlink detector; this grep string comes from the config
 		# variable name and will not be translated.
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesSymlink output
+		test_i18ngrep gitmodulesSymlink output
 	)
 '
 
@@ -172,7 +172,7 @@ test_expect_success 'fsck detects non-blob .gitmodules' '
 		git ls-tree HEAD | sed s/subdir/.gitmodules/ | git mktree &&
 
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesBlob output
+		test_i18ngrep gitmodulesBlob output
 	)
 '
 
@@ -186,7 +186,7 @@ test_expect_success 'fsck detects corrupt .gitmodules' '
 		git commit -m "broken gitmodules" &&
 
 		git fsck 2>output &&
-		grep gitmodulesParse output &&
+		test_i18ngrep gitmodulesParse output &&
 		test_i18ngrep ! "bad config" output
 	)
 '
-- 
2.19.1.1005.gac84295441


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

* Re: [PATCH v2 01/16] git.c: mark more strings for translation
  2018-11-05 19:20   ` [PATCH v2 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:02     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:02 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> One string is slightly updated to keep consistency with the rest:
> die() should with lowercase.

s/should/& begin/, I think, in which case I could locally touch up.


>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  git.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/git.c b/git.c
> index adac132956..5fd30da093 100644
> --- a/git.c
> +++ b/git.c
> @@ -338,27 +338,27 @@ static int handle_alias(int *argcp, const char ***argv)
>  			if (ret >= 0)   /* normal exit */
>  				exit(ret);
>  
> -			die_errno("while expanding alias '%s': '%s'",
> -			    alias_command, alias_string + 1);
> +			die_errno(_("while expanding alias '%s': '%s'"),
> +				  alias_command, alias_string + 1);
>  		}
>  		count = split_cmdline(alias_string, &new_argv);
>  		if (count < 0)
> -			die("Bad alias.%s string: %s", alias_command,
> +			die(_("bad alias.%s string: %s"), alias_command,
>  			    split_cmdline_strerror(count));
>  		option_count = handle_options(&new_argv, &count, &envchanged);
>  		if (envchanged)
> -			die("alias '%s' changes environment variables.\n"
> -				 "You can use '!git' in the alias to do this",
> -				 alias_command);
> +			die(_("alias '%s' changes environment variables.\n"
> +			      "You can use '!git' in the alias to do this"),
> +			    alias_command);
>  		memmove(new_argv - option_count, new_argv,
>  				count * sizeof(char *));
>  		new_argv -= option_count;
>  
>  		if (count < 1)
> -			die("empty alias for %s", alias_command);
> +			die(_("empty alias for %s"), alias_command);
>  
>  		if (!strcmp(alias_command, new_argv[0]))
> -			die("recursive alias: %s", alias_command);
> +			die(_("recursive alias: %s"), alias_command);
>  
>  		trace_argv_printf(new_argv,
>  				  "trace: alias expansion: %s =>",
> @@ -409,7 +409,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
>  
>  	if (!help && get_super_prefix()) {
>  		if (!(p->option & SUPPORT_SUPER_PREFIX))
> -			die("%s doesn't support --super-prefix", p->cmd);
> +			die(_("%s doesn't support --super-prefix"), p->cmd);
>  	}
>  
>  	if (!help && p->option & NEED_WORK_TREE)
> @@ -433,11 +433,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
>  
>  	/* Check for ENOSPC and EIO errors.. */
>  	if (fflush(stdout))
> -		die_errno("write failure on standard output");
> +		die_errno(_("write failure on standard output"));
>  	if (ferror(stdout))
> -		die("unknown write failure on standard output");
> +		die(_("unknown write failure on standard output"));
>  	if (fclose(stdout))
> -		die_errno("close failed on standard output");
> +		die_errno(_("close failed on standard output"));
>  	return 0;
>  }
>  
> @@ -648,7 +648,7 @@ static void execv_dashed_external(const char **argv)
>  	int status;
>  
>  	if (get_super_prefix())
> -		die("%s doesn't support --super-prefix", argv[0]);
> +		die(_("%s doesn't support --super-prefix"), argv[0]);
>  
>  	if (use_pager == -1 && !is_builtin(argv[0]))
>  		use_pager = check_pager_config(argv[0]);
> @@ -760,7 +760,7 @@ int cmd_main(int argc, const char **argv)
>  	if (skip_prefix(cmd, "git-", &cmd)) {
>  		argv[0] = cmd;
>  		handle_builtin(argc, argv);
> -		die("cannot handle %s as a builtin", cmd);
> +		die(_("cannot handle %s as a builtin"), cmd);
>  	}
>  
>  	/* Look for flags.. */
> @@ -773,7 +773,7 @@ int cmd_main(int argc, const char **argv)
>  	} else {
>  		/* The user didn't specify a command; give them help */
>  		commit_pager_choice();
> -		printf("usage: %s\n\n", git_usage_string);
> +		printf(_("usage: %s\n\n"), git_usage_string);
>  		list_common_cmds_help();
>  		printf("\n%s\n", _(git_more_info_string));
>  		exit(1);

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

* Re: [PATCH v2 03/16] archive.c: mark more strings for translation
  2018-11-05 19:20   ` [PATCH v2 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:09     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:09 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Two messages also print extra information to be more useful
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  archive.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/archive.c b/archive.c
> index 9d16b7fadf..d8f6e1ce30 100644
> --- a/archive.c
> +++ b/archive.c
> @@ -385,12 +385,12 @@ static void parse_treeish_arg(const char **argv,
>  		int refnamelen = colon - name;
>  
>  		if (!dwim_ref(name, refnamelen, &oid, &ref))
> -			die("no such ref: %.*s", refnamelen, name);
> +			die(_("no such ref: %.*s"), refnamelen, name);
>  		free(ref);
>  	}
>  
>  	if (get_oid(name, &oid))
> -		die("Not a valid object name");
> +		die(_("not a valid object name: %s"), name);

Much better than the previous one that gave the name upfront.

>  
>  	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
>  	if (commit) {
> @@ -403,7 +403,7 @@ static void parse_treeish_arg(const char **argv,
>  
>  	tree = parse_tree_indirect(&oid);
>  	if (tree == NULL)
> -		die("not a tree object");
> +		die(_("not a tree object: %s"), oid_to_hex(&oid));

Likewise; as oid_to_hex() would be quite long compared to the rest
of the message, this is a vast improvement from the previous round.

>  	if (prefix) {
>  		struct object_id tree_oid;
> @@ -413,7 +413,7 @@ static void parse_treeish_arg(const char **argv,
>  		err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
>  				     &mode);
>  		if (err || !S_ISDIR(mode))
> -			die("current working directory is untracked");
> +			die(_("current working directory is untracked"));
>  
>  		tree = parse_tree_indirect(&tree_oid);
>  	}

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

* Re: [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG()
  2018-11-05 19:20   ` [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:10     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:10 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  read-cache.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Makes sense; thanks.

>
> diff --git a/read-cache.c b/read-cache.c
> index d57958233e..0c37f4885e 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -316,7 +316,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
>  			changed |= DATA_CHANGED;
>  		return changed;
>  	default:
> -		die("internal error: ce_mode is %o", ce->ce_mode);
> +		BUG("unsupported ce_mode: %o", ce->ce_mode);
>  	}
>  
>  	changed |= match_stat_data(&ce->ce_stat_data, st);
> @@ -2356,14 +2356,14 @@ void validate_cache_entries(const struct index_state *istate)
>  
>  	for (i = 0; i < istate->cache_nr; i++) {
>  		if (!istate) {
> -			die("internal error: cache entry is not allocated from expected memory pool");
> +			BUG("cache entry is not allocated from expected memory pool");
>  		} else if (!istate->ce_mem_pool ||
>  			!mem_pool_contains(istate->ce_mem_pool, istate->cache[i])) {
>  			if (!istate->split_index ||
>  				!istate->split_index->base ||
>  				!istate->split_index->base->ce_mem_pool ||
>  				!mem_pool_contains(istate->split_index->base->ce_mem_pool, istate->cache[i])) {
> -				die("internal error: cache entry is not allocated from expected memory pool");
> +				BUG("cache entry is not allocated from expected memory pool");
>  			}
>  		}
>  	}

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

* Re: [PATCH v2 07/16] read-cache.c: add missing colon separators
  2018-11-05 19:20   ` [PATCH v2 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:12     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:12 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> typechange_fmt and added_fmt should have a colon before "needs
> update". Align the statements to make it easier to read and see. Also
> drop the unnecessary ().
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  read-cache.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Sensible.  Thanks.

> diff --git a/read-cache.c b/read-cache.c
> index 858befe738..8d99ae376c 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1492,11 +1492,11 @@ int refresh_index(struct index_state *istate, unsigned int flags,
>  						  istate->cache_nr);
>  
>  	trace_performance_enter();
> -	modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
> -	deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
> -	typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
> -	added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
> -	unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
> +	modified_fmt   = in_porcelain ? "M\t%s\n" : "%s: needs update\n";
> +	deleted_fmt    = in_porcelain ? "D\t%s\n" : "%s: needs update\n";
> +	typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n";
> +	added_fmt      = in_porcelain ? "A\t%s\n" : "%s: needs update\n";
> +	unmerged_fmt   = in_porcelain ? "U\t%s\n" : "%s: needs merge\n";
>  	for (i = 0; i < istate->cache_nr; i++) {
>  		struct cache_entry *ce, *new_entry;
>  		int cache_errno = 0;

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

* Re: [PATCH v2 08/16] reflog: mark strings for translation
  2018-11-05 19:20   ` [PATCH v2 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:13     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:13 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

>  	if (argc - i < 1)
> -		return error("Nothing to delete?");
> +		return error(_("no reflog specified to delete"));

Better.  Thanks.


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

* Re: [PATCH v2 09/16] remote.c: turn some error() or die() to BUG()
  2018-11-05 19:20   ` [PATCH v2 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:21     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:21 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> The first error, "internal error", is clearly a BUG(). The second two
> are meant to catch calls with invalid parameters and should never
> happen outside the test suite.

Sounds as if it would happen inside test suites.

I guess by "inside the test suite" you mean a test that links broken
callers to this code as if it is a piece of library function, but
"should never happen, even with invalid or malformed end-user
request" would convey the point better, as the normal part of
testing that is done by driing "git we just built from the command
line should not hit these.

The changes all look sensible.  Thanks.

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  remote.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/remote.c b/remote.c
> index 81f4f01b00..257630ff21 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -620,7 +620,7 @@ static void handle_duplicate(struct ref *ref1, struct ref *ref2)
>  			 * FETCH_HEAD_IGNORE entries always appear at
>  			 * the end of the list.
>  			 */
> -			die(_("Internal error"));
> +			BUG("Internal error");
>  		}
>  	}
>  	free(ref2->peer_ref);
> @@ -707,7 +707,7 @@ static void query_refspecs_multiple(struct refspec *rs,
>  	int find_src = !query->src;
>  
>  	if (find_src && !query->dst)
> -		error("query_refspecs_multiple: need either src or dst");
> +		BUG("query_refspecs_multiple: need either src or dst");
>  
>  	for (i = 0; i < rs->nr; i++) {
>  		struct refspec_item *refspec = &rs->items[i];
> @@ -735,7 +735,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
>  	char **result = find_src ? &query->src : &query->dst;
>  
>  	if (find_src && !query->dst)
> -		return error("query_refspecs: need either src or dst");
> +		BUG("query_refspecs: need either src or dst");
>  
>  	for (i = 0; i < rs->nr; i++) {
>  		struct refspec_item *refspec = &rs->items[i];

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

* Re: [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-05 19:20   ` [PATCH v2 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
@ 2018-11-06  2:33     ` Junio C Hamano
  2018-11-06 14:02       ` Ramsay Jones
  0 siblings, 1 reply; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  2:33 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> There are a few issues with opterror()
>
> - it tries to assemble an English sentence from pieces. This is not
>   great for translators because we give them pieces instead of a full
>   sentence.
>
> - It's a wrapper around error() and needs some hack to let the
>   compiler know it always returns -1.
>
> - Since it takes a string instead of printf format, one call site has
>   to assemble the string manually before passing to it.
>
> Kill it and produce the option name with optname(). The user will use
> error() directly. This solves the second and third problems.

The proposed log message is not very friendly to reviewers, as there
is no hint what optname() does nor where it came from; it turns out
that this patch introduces it.

    Introduce optname() that does the early half of original
    opterror() to come up with the name of the option reported back
    to the user, and use it to kill opterror().  The callers of
    opterror() now directly call error() using the string returned
    by opterror() instead.

or something like that perhaps.

Theoretically not very friendly to topics in flight, but I do not
expect there would be any right now that wants to add new callers of
opterror().

I do agree with the reasoning behind this change.  Thanks for
working on it.

>
> It kind helps the first problem as well because "%s does foo" does
> give a translator a full sentence in a sense and let them reorder if
> needed. But it has limitations, if the subject part has to change
> based on the rest of the sentence, that language is screwed. This is
> also why I try to avoid calling optname() when 'flags' is known in
> advance.
>
> Mark of these strings for translation as well while at there.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/merge.c     |  2 +-
>  builtin/revert.c    |  3 ++-
>  parse-options-cb.c  |  7 ++++---
>  parse-options.c     | 46 +++++++++++++++++++++++++--------------------
>  parse-options.h     |  5 +----
>  ref-filter.c        |  8 +++++---
>  t/t4211-line-log.sh |  2 +-
>  7 files changed, 40 insertions(+), 33 deletions(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 92ba7e1c6d..82248d43c3 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -128,7 +128,7 @@ static int option_read_message(struct parse_opt_ctx_t *ctx,
>  		ctx->argc--;
>  		arg = *++ctx->argv;
>  	} else
> -		return opterror(opt, "requires a value", 0);
> +		return error(_("option `%s' requires a value"), opt->long_name);
>  
>  	if (buf->len)
>  		strbuf_addch(buf, '\n');
> diff --git a/builtin/revert.c b/builtin/revert.c
> index c93393c89b..11190d2ab4 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -69,7 +69,8 @@ static int option_parse_m(const struct option *opt,
>  
>  	replay->mainline = strtol(arg, &end, 10);
>  	if (*end || replay->mainline <= 0)
> -		return opterror(opt, "expects a number greater than zero", 0);
> +		return error(_("option `%s' expects a number greater than zero"),
> +			     opt->long_name);
>  
>  	return 0;
>  }
> diff --git a/parse-options-cb.c b/parse-options-cb.c
> index e8236534ac..813eb6301b 100644
> --- a/parse-options-cb.c
> +++ b/parse-options-cb.c
> @@ -18,7 +18,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
>  	} else {
>  		v = strtol(arg, (char **)&arg, 10);
>  		if (*arg)
> -			return opterror(opt, "expects a numerical value", 0);
> +			return error(_("option `%s' expects a numerical value"),
> +				     opt->long_name);
>  		if (v && v < MINIMUM_ABBREV)
>  			v = MINIMUM_ABBREV;
>  		else if (v > 40)
> @@ -54,8 +55,8 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
>  		arg = unset ? "never" : (const char *)opt->defval;
>  	value = git_config_colorbool(NULL, arg);
>  	if (value < 0)
> -		return opterror(opt,
> -			"expects \"always\", \"auto\", or \"never\"", 0);
> +		return error(_("option `%s' expects \"always\", \"auto\", or \"never\""),
> +			     opt->long_name);
>  	*(int *)opt->value = value;
>  	return 0;
>  }
> diff --git a/parse-options.c b/parse-options.c
> index 3b874a83a0..0bf817193d 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -32,7 +32,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
>  		p->argc--;
>  		*arg = *++p->argv;
>  	} else
> -		return opterror(opt, "requires a value", flags);
> +		return error(_("%s requires a value"), optname(opt, flags));
>  	return 0;
>  }
>  
> @@ -49,7 +49,6 @@ static int opt_command_mode_error(const struct option *opt,
>  				  int flags)
>  {
>  	const struct option *that;
> -	struct strbuf message = STRBUF_INIT;
>  	struct strbuf that_name = STRBUF_INIT;
>  
>  	/*
> @@ -67,13 +66,13 @@ static int opt_command_mode_error(const struct option *opt,
>  			strbuf_addf(&that_name, "--%s", that->long_name);
>  		else
>  			strbuf_addf(&that_name, "-%c", that->short_name);
> -		strbuf_addf(&message, ": incompatible with %s", that_name.buf);
> +		error(_("%s is incompatible with %s"),
> +		      optname(opt, flags), that_name.buf);
>  		strbuf_release(&that_name);
> -		opterror(opt, message.buf, flags);
> -		strbuf_release(&message);
>  		return -1;
>  	}
> -	return opterror(opt, ": incompatible with something else", flags);
> +	return error(_("%s : incompatible with something else"),
> +		     optname(opt, flags));
>  }
>  
>  static int get_value(struct parse_opt_ctx_t *p,
> @@ -86,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p,
>  	int err;
>  
>  	if (unset && p->opt)
> -		return opterror(opt, "takes no value", flags);
> +		return error(_("%s takes no value"), optname(opt, flags));
>  	if (unset && (opt->flags & PARSE_OPT_NONEG))
> -		return opterror(opt, "isn't available", flags);
> +		return error(_("%s isn't available"), optname(opt, flags));
>  	if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
> -		return opterror(opt, "takes no value", flags);
> +		return error(_("%s takes no value"), optname(opt, flags));
>  
>  	switch (opt->type) {
>  	case OPTION_LOWLEVEL_CALLBACK:
> @@ -176,7 +175,8 @@ static int get_value(struct parse_opt_ctx_t *p,
>  			return -1;
>  		*(int *)opt->value = strtol(arg, (char **)&s, 10);
>  		if (*s)
> -			return opterror(opt, "expects a numerical value", flags);
> +			return error(_("%s expects a numerical value"),
> +				     optname(opt, flags));
>  		return 0;
>  
>  	case OPTION_MAGNITUDE:
> @@ -191,9 +191,9 @@ static int get_value(struct parse_opt_ctx_t *p,
>  		if (get_arg(p, opt, flags, &arg))
>  			return -1;
>  		if (!git_parse_ulong(arg, opt->value))
> -			return opterror(opt,
> -				"expects a non-negative integer value with an optional k/m/g suffix",
> -				flags);
> +			return error(_("%s expects a non-negative integer value"
> +				       " with an optional k/m/g suffix"),
> +				     optname(opt, flags));
>  		return 0;
>  
>  	default:
> @@ -257,7 +257,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
>  			if (!rest)
>  				continue;
>  			if (*rest == '=')
> -				return opterror(options, "takes no value", flags);
> +				return error(_("%s takes no value"),
> +					     optname(options, flags));
>  			if (*rest)
>  				continue;
>  			p->out[p->cpidx++] = arg - 2;
> @@ -773,12 +774,17 @@ void NORETURN usage_msg_opt(const char *msg,
>  	usage_with_options(usagestr, options);
>  }
>  
> -#undef opterror
> -int opterror(const struct option *opt, const char *reason, int flags)
> +const char *optname(const struct option *opt, int flags)
>  {
> +	static struct strbuf sb = STRBUF_INIT;
> +
> +	strbuf_reset(&sb);
>  	if (flags & OPT_SHORT)
> -		return error("switch `%c' %s", opt->short_name, reason);
> -	if (flags & OPT_UNSET)
> -		return error("option `no-%s' %s", opt->long_name, reason);
> -	return error("option `%s' %s", opt->long_name, reason);
> +		strbuf_addf(&sb, "switch `%c'", opt->short_name);
> +	else if (flags & OPT_UNSET)
> +		strbuf_addf(&sb, "option `no-%s'", opt->long_name);
> +	else
> +		strbuf_addf(&sb, "option `%s'", opt->long_name);
> +
> +	return sb.buf;
>  }
> diff --git a/parse-options.h b/parse-options.h
> index dd14911a29..2e146aa6fa 100644
> --- a/parse-options.h
> +++ b/parse-options.h
> @@ -189,10 +189,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
>  				   const struct option *options);
>  
>  extern int optbug(const struct option *opt, const char *reason);
> -extern int opterror(const struct option *opt, const char *reason, int flags);
> -#if defined(__GNUC__)
> -#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
> -#endif
> +const char *optname(const struct option *opt, int flags);
>  
>  /*----- incremental advanced APIs -----*/
>  
> diff --git a/ref-filter.c b/ref-filter.c
> index 2a05619211..0681359100 100644
> --- a/ref-filter.c
> +++ b/ref-filter.c
> @@ -2302,9 +2302,11 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
>  
>  	if (rf->merge) {
>  		if (no_merged) {
> -			return opterror(opt, "is incompatible with --merged", 0);
> +			return error(_("option `%s' is incompatible with --merged"),
> +				     opt->long_name);
>  		} else {
> -			return opterror(opt, "is incompatible with --no-merged", 0);
> +			return error(_("option `%s' is incompatible with --no-merged"),
> +				     opt->long_name);
>  		}
>  	}
>  
> @@ -2318,7 +2320,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
>  	rf->merge_commit = lookup_commit_reference_gently(the_repository,
>  							  &oid, 0);
>  	if (!rf->merge_commit)
> -		return opterror(opt, "must point to a commit", 0);
> +		return error(_("option `%s' must point to a commit"), opt->long_name);
>  
>  	return 0;
>  }
> diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
> index ef1322148e..bd5fe4d148 100755
> --- a/t/t4211-line-log.sh
> +++ b/t/t4211-line-log.sh
> @@ -25,7 +25,7 @@ canned_test_failure () {
>  test_bad_opts () {
>  	test_expect_success "invalid args: $1" "
>  		test_must_fail git log $1 2>errors &&
> -		grep '$2' errors
> +		test_i18ngrep '$2' errors
>  	"
>  }

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

* Re: [PATCH v2 13/16] parse-options.c: turn some die() to BUG()
  2018-11-05 19:20   ` [PATCH v2 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-06  3:27     ` Junio C Hamano
  0 siblings, 0 replies; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  3:27 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> diff --git a/parse-options.c b/parse-options.c
> index 0bf817193d..3f5f985c1e 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -197,7 +197,7 @@ static int get_value(struct parse_opt_ctx_t *p,
>  		return 0;
>  
>  	default:
> -		die("should not happen, someone must be hit on the forehead");
> +		BUG("opt->type %d should not happen", opt->type);
>  	}
>  }

OK, this should not happen.

> @@ -424,7 +424,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
>  	ctx->flags = flags;
>  	if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
>  	    (flags & PARSE_OPT_STOP_AT_NON_OPTION))
> -		die("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
> +		BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");

The correctness of this conversion was not immediately obvious, as
"git rev-parse --parse-options" could allow end-users to specify
flags, and when these two flags came together from that codepath, it
is an end-user error that should be diagnosed with die(), not BUG().

It turns out that stop-at-non-option can be passed, but keep-unknown
is not (yet) available to the codepath, so this conversion to BUG()
is correct---an end user futzing with Git correctly compiled from a
bug-free source should not be able to trigger this.

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

* Re: [PATCH v2 15/16] fsck: reduce word legos to help i18n
  2018-11-05 19:20   ` [PATCH v2 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
@ 2018-11-06  3:41     ` Junio C Hamano
  2018-11-10  4:59       ` Duy Nguyen
  0 siblings, 1 reply; 71+ messages in thread
From: Junio C Hamano @ 2018-11-06  3:41 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

>  static const char *describe_object(struct object *obj)
>  {
> -	static struct strbuf buf = STRBUF_INIT;
> -	char *name = name_objects ?
> -		lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
> +	static struct strbuf bufs[4] = {
> +		STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
> +	};

If you need to repeat _INIT anyway, perhaps you want to actively
omit the 4 from above, no?  If you typed 6 by mistake instead, you'd
be in trouble when using the last two elements.

>  static int objerror(struct object *obj, const char *err)
>  {
>  	errors_found |= ERROR_OBJECT;
> -	objreport(obj, "error", err);
> +	fprintf_ln(stderr, "error in %s %s: %s",
> +		   printable_type(obj), describe_object(obj), err);
>  	return -1;
>  }

Makes sense.

>  static int fsck_error_func(struct fsck_options *o,
>  	struct object *obj, int type, const char *message)
>  {
> -	objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
> -	return (type == FSCK_WARN) ? 0 : 1;
> +	if (type == FSCK_WARN) {
> +		fprintf_ln(stderr, "warning in %s %s: %s",
> +			   printable_type(obj), describe_object(obj), message);
> +		return 0;
> +	}
> +
> +	fprintf_ln(stderr, "error in %s %s: %s",
> +		   printable_type(obj), describe_object(obj), message);
> +	return 1;

Make it look more symmetrical like the original, perhaps by

	if (type == FSCK_WARN) {
		...
		return 0;
	} else { /* FSCK_ERROR */
		...
		return 1;
	}

Actually, wouldn't it be clearer to see what is going on, if we did
it like this instead?

	const char *fmt = (type == FSCK_WARN) 
		? N_("warning in %s %s: %s")
		: N_("error in %s %s: %s");
	fprintf_ln(stderr, _(fmt),
		   printable_type(obj), describe_object(obj), message);
	return (type == FSCK_WARN) ? 0 : 1;

It would show that in either case we show these three things in the
message.  I dunno.

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

* Re: [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-06  2:33     ` Junio C Hamano
@ 2018-11-06 14:02       ` Ramsay Jones
  2018-11-06 19:08         ` Jeff King
  2018-11-10  4:55         ` Duy Nguyen
  0 siblings, 2 replies; 71+ messages in thread
From: Ramsay Jones @ 2018-11-06 14:02 UTC (permalink / raw)
  To: Junio C Hamano, Nguyễn Thái Ngọc Duy
  Cc: git, SZEDER Gábor



On 06/11/2018 02:33, Junio C Hamano wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> 
>> There are a few issues with opterror()
>>
>> - it tries to assemble an English sentence from pieces. This is not
>>   great for translators because we give them pieces instead of a full
>>   sentence.
>>
>> - It's a wrapper around error() and needs some hack to let the
>>   compiler know it always returns -1.
>>
>> - Since it takes a string instead of printf format, one call site has
>>   to assemble the string manually before passing to it.
>>
>> Kill it and produce the option name with optname(). The user will use
>> error() directly. This solves the second and third problems.
> 
> The proposed log message is not very friendly to reviewers, as there
> is no hint what optname() does nor where it came from; it turns out
> that this patch introduces it.
> 
>     Introduce optname() that does the early half of original
>     opterror() to come up with the name of the option reported back
>     to the user, and use it to kill opterror().  The callers of
>     opterror() now directly call error() using the string returned
>     by opterror() instead.
> 
> or something like that perhaps.
> 
> Theoretically not very friendly to topics in flight, but I do not
> expect there would be any right now that wants to add new callers of
> opterror().
> 
> I do agree with the reasoning behind this change.  Thanks for
> working on it.
> 

Also, this patch does not replace opterror() calls outside of
the 'parse-options.c' file with optname(). This tickles my
static-check.pl script, since optname() is an external function
which is only called from 'parse-options.c'.

So, at present, optname() could be marked as a local 'static'
symbol. However, I could also imagine it being used by new callers
outside of 'parse-options.c' in the future. (maybe) Your call. ;-)

ATB,
Ramsay Jones


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

* Re: [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-06 14:02       ` Ramsay Jones
@ 2018-11-06 19:08         ` Jeff King
  2018-11-10  4:55         ` Duy Nguyen
  1 sibling, 0 replies; 71+ messages in thread
From: Jeff King @ 2018-11-06 19:08 UTC (permalink / raw)
  To: Ramsay Jones
  Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy, git,
	SZEDER Gábor

On Tue, Nov 06, 2018 at 02:02:42PM +0000, Ramsay Jones wrote:

> Also, this patch does not replace opterror() calls outside of
> the 'parse-options.c' file with optname(). This tickles my
> static-check.pl script, since optname() is an external function
> which is only called from 'parse-options.c'.
> 
> So, at present, optname() could be marked as a local 'static'
> symbol. However, I could also imagine it being used by new callers
> outside of 'parse-options.c' in the future. (maybe) Your call. ;-)

One potential caller is the BUG() cases I added in:

  https://public-inbox.org/git/20181105064542.GM25864@sigill.intra.peff.net/

I actually thought about factoring out an optname() there, but saw that
it involved memory ownership issues and punted (since those messages are
just BUG()s anyway, and unlikely to be triggered). But if we have it, we
could use it.

-Peff

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

* Re: [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-06 14:02       ` Ramsay Jones
  2018-11-06 19:08         ` Jeff King
@ 2018-11-10  4:55         ` Duy Nguyen
  2018-11-10 14:59           ` Ramsay Jones
  1 sibling, 1 reply; 71+ messages in thread
From: Duy Nguyen @ 2018-11-10  4:55 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Junio C Hamano, Git Mailing List, SZEDER Gábor

On Tue, Nov 6, 2018 at 3:07 PM Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:
> Also, this patch does not replace opterror() calls outside of
> the 'parse-options.c' file with optname(). This tickles my
> static-check.pl script, since optname() is an external function
> which is only called from 'parse-options.c'.
>
> So, at present, optname() could be marked as a local 'static'
> symbol. However, I could also imagine it being used by new callers
> outside of 'parse-options.c' in the future. (maybe) Your call. ;-)

I was making it static, but the compiler complained about undefined
function and I would need to either move optname() up in
parse-options.c or add a forward declaration (but I was going to
_remove_ the declaration!)

Since it could be potentially used by Jeff's series (and I think it
does have potential in parse-options-cb.c), I'll just leave it
exported and caress your static-check.pl script (how did it not catch
optbug() not being used outside parse-options.c either)?
-- 
Duy

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

* Re: [PATCH v2 15/16] fsck: reduce word legos to help i18n
  2018-11-06  3:41     ` Junio C Hamano
@ 2018-11-10  4:59       ` Duy Nguyen
  0 siblings, 0 replies; 71+ messages in thread
From: Duy Nguyen @ 2018-11-10  4:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, SZEDER Gábor

On Tue, Nov 6, 2018 at 4:41 AM Junio C Hamano <gitster@pobox.com> wrote:
> >  static int fsck_error_func(struct fsck_options *o,
> >       struct object *obj, int type, const char *message)
> >  {
> > -     objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
> > -     return (type == FSCK_WARN) ? 0 : 1;
> > +     if (type == FSCK_WARN) {
> > +             fprintf_ln(stderr, "warning in %s %s: %s",
> > +                        printable_type(obj), describe_object(obj), message);
> > +             return 0;
> > +     }
> > +
> > +     fprintf_ln(stderr, "error in %s %s: %s",
> > +                printable_type(obj), describe_object(obj), message);
> > +     return 1;
>
> Make it look more symmetrical like the original, perhaps by
>
>         if (type == FSCK_WARN) {
>                 ...
>                 return 0;
>         } else { /* FSCK_ERROR */
>                 ...
>                 return 1;
>         }
>
> Actually, wouldn't it be clearer to see what is going on, if we did
> it like this instead?
>
>         const char *fmt = (type == FSCK_WARN)
>                 ? N_("warning in %s %s: %s")
>                 : N_("error in %s %s: %s");
>         fprintf_ln(stderr, _(fmt),
>                    printable_type(obj), describe_object(obj), message);
>         return (type == FSCK_WARN) ? 0 : 1;
>
> It would show that in either case we show these three things in the
> message.  I dunno.

Specifying "type == FSCK_WARN" twice triggers me (what if we add a
third fsck type?) so I just turn this to a switch/case block instead
(and get to know the third fsck type FSCK_IGNORE).
-- 
Duy

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

* [PATCH v3 00/16] Mark more strings for translation
  2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
                     ` (15 preceding siblings ...)
  2018-11-05 19:20   ` [PATCH v2 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:15   ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
                       ` (15 more replies)
  16 siblings, 16 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:15 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

v3 is just small touchups here and there after the review comments
from v2.

Range-diff against v2:
 1:  e77c203313 !  1:  936f84d4b3 git.c: mark more strings for translation
    @@ -3,7 +3,7 @@
         git.c: mark more strings for translation
     
         One string is slightly updated to keep consistency with the rest:
    -    die() should with lowercase.
    +    die() should begin with lowercase.
     
      diff --git a/git.c b/git.c
      --- a/git.c
 2:  12c9468696 =  2:  8ff2de14bf alias.c: mark split_cmdline_strerror() strings for translation
 3:  bf662dc105 =  3:  8e147f6bff archive.c: mark more strings for translation
 4:  1d032b0fdf =  4:  5d574460eb attr.c: mark more string for translation
 5:  2c3ad8c262 =  5:  8e37efb756 read-cache.c: turn die("internal error") to BUG()
 6:  df25ac78b1 =  6:  83b7b6d029 read-cache.c: mark more strings for translation
 7:  241e5a7450 =  7:  4bd085682d read-cache.c: add missing colon separators
 8:  8f60728b0f =  8:  fb72be3a1e reflog: mark strings for translation
 9:  24d2ed6682 =  9:  711812d70b remote.c: turn some error() or die() to BUG()
10:  26e8cee291 = 10:  0213c1f5eb remote.c: mark messages for translation
11:  2409f76902 = 11:  85459c65ca repack: mark more strings for translation
12:  afafe6771c ! 12:  21916a8fb4 parse-options: replace opterror() with optname()
    @@ -2,6 +2,11 @@
     
         parse-options: replace opterror() with optname()
     
    +    Introduce optname() that does the early half of original opterror() to
    +    come up with the name of the option reported back to the user, and use
    +    it to kill opterror().  The callers of opterror() now directly call
    +    error() using the string returned by opterror() instead.
    +
         There are a few issues with opterror()
     
         - it tries to assemble an English sentence from pieces. This is not
    @@ -14,8 +19,7 @@
         - Since it takes a string instead of printf format, one call site has
           to assemble the string manually before passing to it.
     
    -    Kill it and produce the option name with optname(). The user will use
    -    error() directly. This solves the second and third problems.
    +    Using error() directly solves the second and third problems.
     
         It kind helps the first problem as well because "%s does foo" does
         give a translator a full sentence in a sense and let them reorder if
13:  e8b4af8fac = 13:  8c9d2985b5 parse-options.c: turn some die() to BUG()
14:  c3530e162e = 14:  b81cdeda46 parse-options.c: mark more strings for translation
15:  644c56780c ! 15:  dd872fc39b fsck: reduce word legos to help i18n
    @@ -19,7 +19,7 @@
     -	static struct strbuf buf = STRBUF_INIT;
     -	char *name = name_objects ?
     -		lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
    -+	static struct strbuf bufs[4] = {
    ++	static struct strbuf bufs[] = {
     +		STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
     +	};
     +	static int b = 0;
    @@ -69,15 +69,18 @@
      {
     -	objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
     -	return (type == FSCK_WARN) ? 0 : 1;
    -+	if (type == FSCK_WARN) {
    ++	switch (type) {
    ++	case FSCK_WARN:
     +		fprintf_ln(stderr, "warning in %s %s: %s",
     +			   printable_type(obj), describe_object(obj), message);
     +		return 0;
    ++	case FSCK_ERROR:
    ++		fprintf_ln(stderr, "error in %s %s: %s",
    ++			   printable_type(obj), describe_object(obj), message);
    ++		return 1;
    ++	default:
    ++		BUG("%d (FSCK_IGNORE?) should never trigger this callback", type);
     +	}
    -+
    -+	fprintf_ln(stderr, "error in %s %s: %s",
    -+		   printable_type(obj), describe_object(obj), message);
    -+	return 1;
      }
      
      static struct object_array pending;
16:  61af36567b ! 16:  8f1bbd1c65 fsck: mark strings for translation
    @@ -28,22 +28,21 @@
      	return -1;
      }
     @@
    - 	struct object *obj, int type, const char *message)
      {
    - 	if (type == FSCK_WARN) {
    + 	switch (type) {
    + 	case FSCK_WARN:
     -		fprintf_ln(stderr, "warning in %s %s: %s",
     +		/* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
     +		fprintf_ln(stderr, _("warning in %s %s: %s"),
      			   printable_type(obj), describe_object(obj), message);
      		return 0;
    - 	}
    - 
    --	fprintf_ln(stderr, "error in %s %s: %s",
    -+	/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
    -+	fprintf_ln(stderr, _("error in %s %s: %s"),
    - 		   printable_type(obj), describe_object(obj), message);
    - 	return 1;
    - }
    + 	case FSCK_ERROR:
    +-		fprintf_ln(stderr, "error in %s %s: %s",
    ++		/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
    ++		fprintf_ln(stderr, _("error in %s %s: %s"),
    + 			   printable_type(obj), describe_object(obj), message);
    + 		return 1;
    + 	default:
     @@
      	 */
      	if (!obj) {

Nguyễn Thái Ngọc Duy (16):
  git.c: mark more strings for translation
  alias.c: mark split_cmdline_strerror() strings for translation
  archive.c: mark more strings for translation
  attr.c: mark more string for translation
  read-cache.c: turn die("internal error") to BUG()
  read-cache.c: mark more strings for translation
  read-cache.c: add missing colon separators
  reflog: mark strings for translation
  remote.c: turn some error() or die() to BUG()
  remote.c: mark messages for translation
  repack: mark more strings for translation
  parse-options: replace opterror() with optname()
  parse-options.c: turn some die() to BUG()
  parse-options.c: mark more strings for translation
  fsck: reduce word legos to help i18n
  fsck: mark strings for translation

 alias.c                    |   4 +-
 archive.c                  |   8 +-
 attr.c                     |   4 +-
 builtin/fsck.c             | 159 +++++++++++++++++++++----------------
 builtin/merge.c            |   4 +-
 builtin/reflog.c           |  34 ++++----
 builtin/repack.c           |  26 +++---
 builtin/revert.c           |   3 +-
 git.c                      |  32 ++++----
 parse-options-cb.c         |   7 +-
 parse-options.c            |  64 ++++++++-------
 parse-options.h            |   5 +-
 read-cache.c               |  73 ++++++++---------
 ref-filter.c               |   8 +-
 remote.c                   |  49 ++++++------
 t/t0040-parse-options.sh   |   4 +-
 t/t1410-reflog.sh          |   6 +-
 t/t1450-fsck.sh            |  52 ++++++------
 t/t4211-line-log.sh        |   2 +-
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +-
 21 files changed, 295 insertions(+), 259 deletions(-)

-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 01/16] git.c: mark more strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
                       ` (14 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

One string is slightly updated to keep consistency with the rest:
die() should begin with lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/git.c b/git.c
index adac132956..5fd30da093 100644
--- a/git.c
+++ b/git.c
@@ -338,27 +338,27 @@ static int handle_alias(int *argcp, const char ***argv)
 			if (ret >= 0)   /* normal exit */
 				exit(ret);
 
-			die_errno("while expanding alias '%s': '%s'",
-			    alias_command, alias_string + 1);
+			die_errno(_("while expanding alias '%s': '%s'"),
+				  alias_command, alias_string + 1);
 		}
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
-			die("Bad alias.%s string: %s", alias_command,
+			die(_("bad alias.%s string: %s"), alias_command,
 			    split_cmdline_strerror(count));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
-			die("alias '%s' changes environment variables.\n"
-				 "You can use '!git' in the alias to do this",
-				 alias_command);
+			die(_("alias '%s' changes environment variables.\n"
+			      "You can use '!git' in the alias to do this"),
+			    alias_command);
 		memmove(new_argv - option_count, new_argv,
 				count * sizeof(char *));
 		new_argv -= option_count;
 
 		if (count < 1)
-			die("empty alias for %s", alias_command);
+			die(_("empty alias for %s"), alias_command);
 
 		if (!strcmp(alias_command, new_argv[0]))
-			die("recursive alias: %s", alias_command);
+			die(_("recursive alias: %s"), alias_command);
 
 		trace_argv_printf(new_argv,
 				  "trace: alias expansion: %s =>",
@@ -409,7 +409,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	if (!help && get_super_prefix()) {
 		if (!(p->option & SUPPORT_SUPER_PREFIX))
-			die("%s doesn't support --super-prefix", p->cmd);
+			die(_("%s doesn't support --super-prefix"), p->cmd);
 	}
 
 	if (!help && p->option & NEED_WORK_TREE)
@@ -433,11 +433,11 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 	/* Check for ENOSPC and EIO errors.. */
 	if (fflush(stdout))
-		die_errno("write failure on standard output");
+		die_errno(_("write failure on standard output"));
 	if (ferror(stdout))
-		die("unknown write failure on standard output");
+		die(_("unknown write failure on standard output"));
 	if (fclose(stdout))
-		die_errno("close failed on standard output");
+		die_errno(_("close failed on standard output"));
 	return 0;
 }
 
@@ -648,7 +648,7 @@ static void execv_dashed_external(const char **argv)
 	int status;
 
 	if (get_super_prefix())
-		die("%s doesn't support --super-prefix", argv[0]);
+		die(_("%s doesn't support --super-prefix"), argv[0]);
 
 	if (use_pager == -1 && !is_builtin(argv[0]))
 		use_pager = check_pager_config(argv[0]);
@@ -760,7 +760,7 @@ int cmd_main(int argc, const char **argv)
 	if (skip_prefix(cmd, "git-", &cmd)) {
 		argv[0] = cmd;
 		handle_builtin(argc, argv);
-		die("cannot handle %s as a builtin", cmd);
+		die(_("cannot handle %s as a builtin"), cmd);
 	}
 
 	/* Look for flags.. */
@@ -773,7 +773,7 @@ int cmd_main(int argc, const char **argv)
 	} else {
 		/* The user didn't specify a command; give them help */
 		commit_pager_choice();
-		printf("usage: %s\n\n", git_usage_string);
+		printf(_("usage: %s\n\n"), git_usage_string);
 		list_common_cmds_help();
 		printf("\n%s\n", _(git_more_info_string));
 		exit(1);
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 02/16] alias.c: mark split_cmdline_strerror() strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
                       ` (13 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

This function can be part of translated messages. To make sure we
don't have a sentence with mixed languages, mark the strings for
translation, but only use translated strings in places we know we will
output translated strings.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 alias.c         | 4 ++--
 builtin/merge.c | 2 +-
 git.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/alias.c b/alias.c
index a7e4e57130..c471538020 100644
--- a/alias.c
+++ b/alias.c
@@ -47,8 +47,8 @@ void list_aliases(struct string_list *list)
 #define SPLIT_CMDLINE_BAD_ENDING 1
 #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
 static const char *split_cmdline_errors[] = {
-	"cmdline ends with \\",
-	"unclosed quote"
+	N_("cmdline ends with \\"),
+	N_("unclosed quote")
 };
 
 int split_cmdline(char *cmdline, const char ***argv)
diff --git a/builtin/merge.c b/builtin/merge.c
index 4aa6071598..92ba7e1c6d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -577,7 +577,7 @@ static void parse_branch_merge_options(char *bmo)
 	argc = split_cmdline(bmo, &argv);
 	if (argc < 0)
 		die(_("Bad branch.%s.mergeoptions string: %s"), branch,
-		    split_cmdline_strerror(argc));
+		    _(split_cmdline_strerror(argc)));
 	REALLOC_ARRAY(argv, argc + 2);
 	MOVE_ARRAY(argv + 1, argv, argc + 1);
 	argc++;
diff --git a/git.c b/git.c
index 5fd30da093..c7e122cfc1 100644
--- a/git.c
+++ b/git.c
@@ -344,7 +344,7 @@ static int handle_alias(int *argcp, const char ***argv)
 		count = split_cmdline(alias_string, &new_argv);
 		if (count < 0)
 			die(_("bad alias.%s string: %s"), alias_command,
-			    split_cmdline_strerror(count));
+			    _(split_cmdline_strerror(count)));
 		option_count = handle_options(&new_argv, &count, &envchanged);
 		if (envchanged)
 			die(_("alias '%s' changes environment variables.\n"
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 03/16] archive.c: mark more strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
                       ` (12 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Two messages also print extra information to be more useful

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 archive.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/archive.c b/archive.c
index 9d16b7fadf..d8f6e1ce30 100644
--- a/archive.c
+++ b/archive.c
@@ -385,12 +385,12 @@ static void parse_treeish_arg(const char **argv,
 		int refnamelen = colon - name;
 
 		if (!dwim_ref(name, refnamelen, &oid, &ref))
-			die("no such ref: %.*s", refnamelen, name);
+			die(_("no such ref: %.*s"), refnamelen, name);
 		free(ref);
 	}
 
 	if (get_oid(name, &oid))
-		die("Not a valid object name");
+		die(_("not a valid object name: %s"), name);
 
 	commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
 	if (commit) {
@@ -403,7 +403,7 @@ static void parse_treeish_arg(const char **argv,
 
 	tree = parse_tree_indirect(&oid);
 	if (tree == NULL)
-		die("not a tree object");
+		die(_("not a tree object: %s"), oid_to_hex(&oid));
 
 	if (prefix) {
 		struct object_id tree_oid;
@@ -413,7 +413,7 @@ static void parse_treeish_arg(const char **argv,
 		err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
 				     &mode);
 		if (err || !S_ISDIR(mode))
-			die("current working directory is untracked");
+			die(_("current working directory is untracked"));
 
 		tree = parse_tree_indirect(&tree_oid);
 	}
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 04/16] attr.c: mark more string for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (2 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
                       ` (11 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/attr.c b/attr.c
index 60d284796d..3770bc1a11 100644
--- a/attr.c
+++ b/attr.c
@@ -372,8 +372,8 @@ static struct match_attr *parse_attr_line(const char *line, const char *src,
 	if (strlen(ATTRIBUTE_MACRO_PREFIX) < namelen &&
 	    starts_with(name, ATTRIBUTE_MACRO_PREFIX)) {
 		if (!macro_ok) {
-			fprintf(stderr, "%s not allowed: %s:%d\n",
-				name, src, lineno);
+			fprintf_ln(stderr, _("%s not allowed: %s:%d"),
+				   name, src, lineno);
 			goto fail_return;
 		}
 		is_macro = 1;
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 05/16] read-cache.c: turn die("internal error") to BUG()
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (3 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
                       ` (10 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index d57958233e..0c37f4885e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -316,7 +316,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
 			changed |= DATA_CHANGED;
 		return changed;
 	default:
-		die("internal error: ce_mode is %o", ce->ce_mode);
+		BUG("unsupported ce_mode: %o", ce->ce_mode);
 	}
 
 	changed |= match_stat_data(&ce->ce_stat_data, st);
@@ -2356,14 +2356,14 @@ void validate_cache_entries(const struct index_state *istate)
 
 	for (i = 0; i < istate->cache_nr; i++) {
 		if (!istate) {
-			die("internal error: cache entry is not allocated from expected memory pool");
+			BUG("cache entry is not allocated from expected memory pool");
 		} else if (!istate->ce_mem_pool ||
 			!mem_pool_contains(istate->ce_mem_pool, istate->cache[i])) {
 			if (!istate->split_index ||
 				!istate->split_index->base ||
 				!istate->split_index->base->ce_mem_pool ||
 				!mem_pool_contains(istate->split_index->base->ce_mem_pool, istate->cache[i])) {
-				die("internal error: cache entry is not allocated from expected memory pool");
+				BUG("cache entry is not allocated from expected memory pool");
 			}
 		}
 	}
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 06/16] read-cache.c: mark more strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (4 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
                       ` (9 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

There are a couple other improvements on these strings as well:

 - add missing colon (as separator)
 - quote paths
 - provide more information on error messages
 - keep first word in lowercase

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c    | 57 +++++++++++++++++++++++++------------------------
 t/t1450-fsck.sh |  2 +-
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 0c37f4885e..858befe738 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -672,7 +672,8 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
 	struct cache_entry *new_entry;
 
 	if (alias->ce_flags & CE_ADDED)
-		die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+		die(_("will not add file alias '%s' ('%s' already exists in index)"),
+		    ce->name, alias->name);
 
 	/* Ok, create the new entry using the name of the existing alias */
 	len = ce_namelen(alias);
@@ -687,7 +688,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
 {
 	struct object_id oid;
 	if (write_object_file("", 0, blob_type, &oid))
-		die("cannot create an empty blob in the object database");
+		die(_("cannot create an empty blob in the object database"));
 	oidcpy(&ce->oid, &oid);
 }
 
@@ -708,7 +709,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		newflags |= HASH_RENORMALIZE;
 
 	if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
-		return error("%s: can only add regular files, symbolic links or git-directories", path);
+		return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
 
 	namelen = strlen(path);
 	if (S_ISDIR(st_mode)) {
@@ -763,7 +764,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 	if (!intent_only) {
 		if (index_path(istate, &ce->oid, path, st, newflags)) {
 			discard_cache_entry(ce);
-			return error("unable to index file %s", path);
+			return error(_("unable to index file '%s'"), path);
 		}
 	} else
 		set_object_name_for_intent_to_add_entry(ce);
@@ -782,7 +783,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
 		discard_cache_entry(ce);
 	else if (add_index_entry(istate, ce, add_option)) {
 		discard_cache_entry(ce);
-		return error("unable to add %s to index", path);
+		return error(_("unable to add '%s' to index"), path);
 	}
 	if (verbose && !was_same)
 		printf("add '%s'\n", path);
@@ -793,7 +794,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
 {
 	struct stat st;
 	if (lstat(path, &st))
-		die_errno("unable to stat '%s'", path);
+		die_errno(_("unable to stat '%s'"), path);
 	return add_to_index(istate, path, &st, flags);
 }
 
@@ -818,7 +819,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -844,7 +845,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o
 	int len;
 
 	if (!verify_path(path, mode)) {
-		error("Invalid path '%s'", path);
+		error(_("invalid path '%s'"), path);
 		return NULL;
 	}
 
@@ -1297,12 +1298,12 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
 	if (!ok_to_add)
 		return -1;
 	if (!verify_path(ce->name, ce->ce_mode))
-		return error("Invalid path '%s'", ce->name);
+		return error(_("invalid path '%s'"), ce->name);
 
 	if (!skip_df_check &&
 	    check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
 		if (!ok_to_replace)
-			return error("'%s' appears as both a file and as a directory",
+			return error(_("'%s' appears as both a file and as a directory"),
 				     ce->name);
 		pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
 		pos = -pos-1;
@@ -1676,10 +1677,10 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	int hdr_version;
 
 	if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
-		return error("bad signature");
+		return error(_("bad signature 0x%08x"), hdr->hdr_signature);
 	hdr_version = ntohl(hdr->hdr_version);
 	if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
-		return error("bad index version %d", hdr_version);
+		return error(_("bad index version %d"), hdr_version);
 
 	if (!verify_index_checksum)
 		return 0;
@@ -1688,7 +1689,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
 	the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
 	the_hash_algo->final_fn(hash, &c);
 	if (!hasheq(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
-		return error("bad index file sha1 signature");
+		return error(_("bad index file sha1 signature"));
 	return 0;
 }
 
@@ -1718,9 +1719,9 @@ static int read_index_extension(struct index_state *istate,
 		break;
 	default:
 		if (*ext < 'A' || 'Z' < *ext)
-			return error("index uses %.4s extension, which we do not understand",
+			return error(_("index uses %.4s extension, which we do not understand"),
 				     ext);
-		fprintf(stderr, "ignoring %.4s extension\n", ext);
+		fprintf_ln(stderr, _("ignoring %.4s extension"), ext);
 		break;
 	}
 	return 0;
@@ -1767,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
 		extended_flags = get_be16(&ondisk2->flags2) << 16;
 		/* We do not yet understand any bit out of CE_EXTENDED_FLAGS */
 		if (extended_flags & ~CE_EXTENDED_FLAGS)
-			die("Unknown index entry format %08x", extended_flags);
+			die(_("unknown index entry format 0x%08x"), extended_flags);
 		flags |= extended_flags;
 		name = ondisk2->name;
 	}
@@ -1840,13 +1841,13 @@ static void check_ce_order(struct index_state *istate)
 		int name_compare = strcmp(ce->name, next_ce->name);
 
 		if (0 < name_compare)
-			die("unordered stage entries in index");
+			die(_("unordered stage entries in index"));
 		if (!name_compare) {
 			if (!ce_stage(ce))
-				die("multiple stage entries for merged file '%s'",
+				die(_("multiple stage entries for merged file '%s'"),
 				    ce->name);
 			if (ce_stage(ce) > ce_stage(next_ce))
-				die("unordered stage entries for '%s'",
+				die(_("unordered stage entries for '%s'"),
 				    ce->name);
 		}
 	}
@@ -2149,19 +2150,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 	if (fd < 0) {
 		if (!must_exist && errno == ENOENT)
 			return 0;
-		die_errno("%s: index file open failed", path);
+		die_errno(_("%s: index file open failed"), path);
 	}
 
 	if (fstat(fd, &st))
-		die_errno("cannot stat the open index");
+		die_errno(_("%s: cannot stat the open index"), path);
 
 	mmap_size = xsize_t(st.st_size);
 	if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz)
-		die("index file smaller than expected");
+		die(_("%s: index file smaller than expected"), path);
 
 	mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
 	if (mmap == MAP_FAILED)
-		die_errno("unable to map index file");
+		die_errno(_("%s: unable to map index file"), path);
 	close(fd);
 
 	hdr = (const struct cache_header *)mmap;
@@ -2243,7 +2244,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 
 unmap:
 	munmap((void *)mmap, mmap_size);
-	die("index file corrupt");
+	die(_("index file corrupt"));
 }
 
 /*
@@ -2255,7 +2256,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 static void freshen_shared_index(const char *shared_index, int warn)
 {
 	if (!check_and_freshen_file(shared_index, 1) && warn)
-		warning("could not freshen shared index '%s'", shared_index);
+		warning(_("could not freshen shared index '%s'"), shared_index);
 }
 
 int read_index_from(struct index_state *istate, const char *path,
@@ -2290,7 +2291,7 @@ int read_index_from(struct index_state *istate, const char *path,
 	base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
 	ret = do_read_index(split_index->base, base_path, 1);
 	if (!oideq(&split_index->base_oid, &split_index->base->oid))
-		die("broken index, expect %s in %s, got %s",
+		die(_("broken index, expect %s in %s, got %s"),
 		    base_oid_hex, base_path,
 		    oid_to_hex(&split_index->base->oid));
 
@@ -3076,7 +3077,7 @@ static int write_shared_index(struct index_state *istate,
 		return ret;
 	ret = adjust_shared_perm(get_tempfile_path(*temp));
 	if (ret) {
-		error("cannot fix permission bits on %s", get_tempfile_path(*temp));
+		error(_("cannot fix permission bits on '%s'"), get_tempfile_path(*temp));
 		return ret;
 	}
 	ret = rename_tempfile(temp,
@@ -3222,7 +3223,7 @@ int read_index_unmerged(struct index_state *istate)
 		new_ce->ce_namelen = len;
 		new_ce->ce_mode = ce->ce_mode;
 		if (add_index_entry(istate, new_ce, ADD_CACHE_SKIP_DFCHECK))
-			return error("%s: cannot drop to stage #0",
+			return error(_("%s: cannot drop to stage #0"),
 				     new_ce->name);
 	}
 	return unmerged;
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 0f2dd26f74..90c765df3a 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -754,7 +754,7 @@ test_expect_success 'detect corrupt index file in fsck' '
 	test_when_finished "mv .git/index.backup .git/index" &&
 	corrupt_index_checksum &&
 	test_must_fail git fsck --cache 2>errors &&
-	grep "bad index file" errors
+	test_i18ngrep "bad index file" errors
 '
 
 test_done
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 07/16] read-cache.c: add missing colon separators
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (5 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
                       ` (8 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

typechange_fmt and added_fmt should have a colon before "needs
update". Align the statements to make it easier to read and see. Also
drop the unnecessary ().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 858befe738..8d99ae376c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1492,11 +1492,11 @@ int refresh_index(struct index_state *istate, unsigned int flags,
 						  istate->cache_nr);
 
 	trace_performance_enter();
-	modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
-	deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
-	typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
-	added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
-	unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
+	modified_fmt   = in_porcelain ? "M\t%s\n" : "%s: needs update\n";
+	deleted_fmt    = in_porcelain ? "D\t%s\n" : "%s: needs update\n";
+	typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n";
+	added_fmt      = in_porcelain ? "A\t%s\n" : "%s: needs update\n";
+	unmerged_fmt   = in_porcelain ? "U\t%s\n" : "%s: needs merge\n";
 	for (i = 0; i < istate->cache_nr; i++) {
 		struct cache_entry *ce, *new_entry;
 		int cache_errno = 0;
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 08/16] reflog: mark strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (6 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
                       ` (7 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

One string "nothing to delete?" is rephrased to be more helpful.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/reflog.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index b5941c1ff3..5a74ccf7ab 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -13,11 +13,15 @@
 
 /* NEEDSWORK: switch to using parse_options */
 static const char reflog_expire_usage[] =
-"git reflog expire [--expire=<time>] [--expire-unreachable=<time>] [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] <refs>...";
+N_("git reflog expire [--expire=<time>] "
+   "[--expire-unreachable=<time>] "
+   "[--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] "
+   "[--verbose] [--all] <refs>...");
 static const char reflog_delete_usage[] =
-"git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] <refs>...";
+N_("git reflog delete [--rewrite] [--updateref] "
+   "[--dry-run | -n] [--verbose] <refs>...");
 static const char reflog_exists_usage[] =
-"git reflog exists <ref>";
+N_("git reflog exists <ref>");
 
 static timestamp_t default_reflog_expire;
 static timestamp_t default_reflog_expire_unreachable;
@@ -556,7 +560,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_expire_usage);
+			usage(_(reflog_expire_usage));
 		else
 			break;
 	}
@@ -569,7 +573,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 	if (cb.cmd.stalefix) {
 		repo_init_revisions(the_repository, &cb.cmd.revs, prefix);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
-			printf("Marking reachable objects...");
+			printf(_("Marking reachable objects..."));
 		mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL);
 		if (flags & EXPIRE_REFLOGS_VERBOSE)
 			putchar('\n');
@@ -598,7 +602,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
 		char *ref;
 		struct object_id oid;
 		if (!dwim_log(argv[i], strlen(argv[i]), &oid, &ref)) {
-			status |= error("%s points nowhere!", argv[i]);
+			status |= error(_("%s points nowhere!"), argv[i]);
 			continue;
 		}
 		set_reflog_expiry_param(&cb.cmd, explicit_expiry, ref);
@@ -644,13 +648,13 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_delete_usage);
+			usage(_(reflog_delete_usage));
 		else
 			break;
 	}
 
 	if (argc - i < 1)
-		return error("Nothing to delete?");
+		return error(_("no reflog specified to delete"));
 
 	for ( ; i < argc; i++) {
 		const char *spec = strstr(argv[i], "@{");
@@ -659,12 +663,12 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
 		int recno;
 
 		if (!spec) {
-			status |= error("Not a reflog: %s", argv[i]);
+			status |= error(_("not a reflog: %s"), argv[i]);
 			continue;
 		}
 
 		if (!dwim_log(argv[i], spec - argv[i], &oid, &ref)) {
-			status |= error("no reflog for '%s'", argv[i]);
+			status |= error(_("no reflog for '%s'"), argv[i]);
 			continue;
 		}
 
@@ -699,7 +703,7 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 			break;
 		}
 		else if (arg[0] == '-')
-			usage(reflog_exists_usage);
+			usage(_(reflog_exists_usage));
 		else
 			break;
 	}
@@ -707,10 +711,10 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
 	start = i;
 
 	if (argc - start != 1)
-		usage(reflog_exists_usage);
+		usage(_(reflog_exists_usage));
 
 	if (check_refname_format(argv[start], REFNAME_ALLOW_ONELEVEL))
-		die("invalid ref format: %s", argv[start]);
+		die(_("invalid ref format: %s"), argv[start]);
 	return !reflog_exists(argv[start]);
 }
 
@@ -719,12 +723,12 @@ static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
  */
 
 static const char reflog_usage[] =
-"git reflog [ show | expire | delete | exists ]";
+N_("git reflog [ show | expire | delete | exists ]");
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
 	if (argc > 1 && !strcmp(argv[1], "-h"))
-		usage(reflog_usage);
+		usage(_(reflog_usage));
 
 	/* With no command, we default to showing it. */
 	if (argc < 2 || *argv[1] == '-')
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 09/16] remote.c: turn some error() or die() to BUG()
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (7 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
                       ` (6 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

The first error, "internal error", is clearly a BUG(). The second two
are meant to catch calls with invalid parameters and should never
happen outside the test suite.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/remote.c b/remote.c
index 81f4f01b00..257630ff21 100644
--- a/remote.c
+++ b/remote.c
@@ -620,7 +620,7 @@ static void handle_duplicate(struct ref *ref1, struct ref *ref2)
 			 * FETCH_HEAD_IGNORE entries always appear at
 			 * the end of the list.
 			 */
-			die(_("Internal error"));
+			BUG("Internal error");
 		}
 	}
 	free(ref2->peer_ref);
@@ -707,7 +707,7 @@ static void query_refspecs_multiple(struct refspec *rs,
 	int find_src = !query->src;
 
 	if (find_src && !query->dst)
-		error("query_refspecs_multiple: need either src or dst");
+		BUG("query_refspecs_multiple: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
@@ -735,7 +735,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
 	char **result = find_src ? &query->src : &query->dst;
 
 	if (find_src && !query->dst)
-		return error("query_refspecs: need either src or dst");
+		BUG("query_refspecs: need either src or dst");
 
 	for (i = 0; i < rs->nr; i++) {
 		struct refspec_item *refspec = &rs->items[i];
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 10/16] remote.c: mark messages for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (8 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
                       ` (5 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

The two strings are slightly modified to be consistent with the rest:
die() and error() start with a lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/remote.c b/remote.c
index 257630ff21..11b33d1625 100644
--- a/remote.c
+++ b/remote.c
@@ -359,7 +359,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		return 0;
 	/* Handle remote.<name>.* variables */
 	if (*name == '/') {
-		warning("Config remote shorthand cannot begin with '/': %s",
+		warning(_("config remote shorthand cannot begin with '/': %s"),
 			name);
 		return 0;
 	}
@@ -406,7 +406,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->receivepack)
 			remote->receivepack = v;
 		else
-			error("more than one receivepack given, using the first");
+			error(_("more than one receivepack given, using the first"));
 	} else if (!strcmp(subkey, "uploadpack")) {
 		const char *v;
 		if (git_config_string(&v, key, value))
@@ -414,7 +414,7 @@ static int handle_config(const char *key, const char *value, void *cb)
 		if (!remote->uploadpack)
 			remote->uploadpack = v;
 		else
-			error("more than one uploadpack given, using the first");
+			error(_("more than one uploadpack given, using the first"));
 	} else if (!strcmp(subkey, "tagopt")) {
 		if (!strcmp(value, "--no-tags"))
 			remote->fetch_tags = -1;
@@ -680,7 +680,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 	size_t namelen;
 	int ret;
 	if (!kstar)
-		die("Key '%s' of pattern had no '*'", key);
+		die(_("key '%s' of pattern had no '*'"), key);
 	klen = kstar - key;
 	ksuffixlen = strlen(kstar + 1);
 	namelen = strlen(name);
@@ -690,7 +690,7 @@ static int match_name_with_pattern(const char *key, const char *name,
 		struct strbuf sb = STRBUF_INIT;
 		const char *vstar = strchr(value, '*');
 		if (!vstar)
-			die("Value '%s' of pattern has no '*'", value);
+			die(_("value '%s' of pattern has no '*'"), value);
 		strbuf_add(&sb, value, vstar - value);
 		strbuf_add(&sb, name + klen, namelen - klen - ksuffixlen);
 		strbuf_addstr(&sb, vstar + 1);
@@ -995,12 +995,12 @@ static int match_explicit_lhs(struct ref *src,
 		 * way to delete 'other' ref at the remote end.
 		 */
 		if (try_explicit_object_name(rs->src, match) < 0)
-			return error("src refspec %s does not match any.", rs->src);
+			return error(_("src refspec %s does not match any"), rs->src);
 		if (allocated_match)
 			*allocated_match = 1;
 		return 0;
 	default:
-		return error("src refspec %s matches more than one.", rs->src);
+		return error(_("src refspec %s matches more than one"), rs->src);
 	}
 }
 
@@ -1030,7 +1030,7 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (!dst_value ||
 		    ((flag & REF_ISSYMREF) &&
 		     !starts_with(dst_value, "refs/heads/")))
-			die("%s cannot be resolved to branch.",
+			die(_("%s cannot be resolved to branch"),
 			    matched_src->name);
 	}
 
@@ -1041,30 +1041,30 @@ static int match_explicit(struct ref *src, struct ref *dst,
 		if (starts_with(dst_value, "refs/"))
 			matched_dst = make_linked_ref(dst_value, dst_tail);
 		else if (is_null_oid(&matched_src->new_oid))
-			error("unable to delete '%s': remote ref does not exist",
+			error(_("unable to delete '%s': remote ref does not exist"),
 			      dst_value);
 		else if ((dst_guess = guess_ref(dst_value, matched_src))) {
 			matched_dst = make_linked_ref(dst_guess, dst_tail);
 			free(dst_guess);
 		} else
-			error("unable to push to unqualified destination: %s\n"
-			      "The destination refspec neither matches an "
-			      "existing ref on the remote nor\n"
-			      "begins with refs/, and we are unable to "
-			      "guess a prefix based on the source ref.",
+			error(_("unable to push to unqualified destination: %s\n"
+				"The destination refspec neither matches an "
+				"existing ref on the remote nor\n"
+				"begins with refs/, and we are unable to "
+				"guess a prefix based on the source ref."),
 			      dst_value);
 		break;
 	default:
 		matched_dst = NULL;
-		error("dst refspec %s matches more than one.",
+		error(_("dst refspec %s matches more than one"),
 		      dst_value);
 		break;
 	}
 	if (!matched_dst)
 		return -1;
 	if (matched_dst->peer_ref)
-		return error("dst ref %s receives from more than one src.",
-		      matched_dst->name);
+		return error(_("dst ref %s receives from more than one src"),
+			     matched_dst->name);
 	else {
 		matched_dst->peer_ref = allocated_src ?
 					matched_src :
@@ -1750,7 +1750,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			ref_map = get_remote_ref(remote_refs, name);
 		}
 		if (!missing_ok && !ref_map)
-			die("Couldn't find remote ref %s", name);
+			die(_("couldn't find remote ref %s"), name);
 		if (ref_map) {
 			ref_map->peer_ref = get_local_ref(refspec->dst);
 			if (ref_map->peer_ref && refspec->force)
@@ -1763,7 +1763,7 @@ int get_fetch_map(const struct ref *remote_refs,
 			if (!starts_with((*rmp)->peer_ref->name, "refs/") ||
 			    check_refname_format((*rmp)->peer_ref->name, 0)) {
 				struct ref *ignore = *rmp;
-				error("* Ignoring funny ref '%s' locally",
+				error(_("* Ignoring funny ref '%s' locally"),
 				      (*rmp)->peer_ref->name);
 				*rmp = (*rmp)->next;
 				free(ignore->peer_ref);
@@ -1858,7 +1858,7 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
 	repo_init_revisions(the_repository, &revs, NULL);
 	setup_revisions(argv.argc, argv.argv, &revs, NULL);
 	if (prepare_revision_walk(&revs))
-		die("revision walk setup failed");
+		die(_("revision walk setup failed"));
 
 	/* ... and count the commits on each side. */
 	while (1) {
@@ -2131,7 +2131,8 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
 	else if (!colon[1])
 		oidclr(&entry->expect);
 	else if (get_oid(colon + 1, &entry->expect))
-		return error("cannot parse expected object name '%s'", colon + 1);
+		return error(_("cannot parse expected object name '%s'"),
+			     colon + 1);
 	return 0;
 }
 
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 11/16] repack: mark more strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (9 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
                       ` (4 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Two strings are slightly updated to be consistent with the rest: die()
starts with lowercase.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/repack.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/builtin/repack.c b/builtin/repack.c
index c6a7943d5c..721f947218 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -197,7 +197,7 @@ static int write_oid(const struct object_id *oid, struct packed_git *pack,
 
 	if (cmd->in == -1) {
 		if (start_command(cmd))
-			die("Could not start pack-objects to repack promisor objects");
+			die(_("could not start pack-objects to repack promisor objects"));
 	}
 
 	xwrite(cmd->in, oid_to_hex(oid), GIT_SHA1_HEXSZ);
@@ -236,7 +236,7 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 		char *promisor_name;
 		int fd;
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects."));
 		string_list_append(names, line.buf);
 
 		/*
@@ -247,13 +247,13 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
 					  line.buf);
 		fd = open(promisor_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
 		if (fd < 0)
-			die_errno("unable to create '%s'", promisor_name);
+			die_errno(_("unable to create '%s'"), promisor_name);
 		close(fd);
 		free(promisor_name);
 	}
 	fclose(out);
 	if (finish_command(&cmd))
-		die("Could not finish pack-objects to repack promisor objects");
+		die(_("could not finish pack-objects to repack promisor objects"));
 }
 
 #define ALL_INTO_ONE 1
@@ -408,7 +408,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	out = xfdopen(cmd.out, "r");
 	while (strbuf_getline_lf(&line, out) != EOF) {
 		if (line.len != 40)
-			die("repack: Expecting 40 character sha1 lines only from pack-objects.");
+			die(_("repack: Expecting 40 character sha1 lines only from pack-objects"));
 		string_list_append(&names, line.buf);
 	}
 	fclose(out);
@@ -417,7 +417,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		return ret;
 
 	if (!names.nr && !po_args.quiet)
-		printf("Nothing new to pack.\n");
+		printf_ln(_("Nothing new to pack."));
 
 	/*
 	 * Ok we have prepared all new packfiles.
@@ -477,13 +477,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		if (rollback_failure.nr) {
 			int i;
 			fprintf(stderr,
-				"WARNING: Some packs in use have been renamed by\n"
-				"WARNING: prefixing old- to their name, in order to\n"
-				"WARNING: replace them with the new version of the\n"
-				"WARNING: file.  But the operation failed, and the\n"
-				"WARNING: attempt to rename them back to their\n"
-				"WARNING: original names also failed.\n"
-				"WARNING: Please rename them in %s manually:\n", packdir);
+				_("WARNING: Some packs in use have been renamed by\n"
+				  "WARNING: prefixing old- to their name, in order to\n"
+				  "WARNING: replace them with the new version of the\n"
+				  "WARNING: file.  But the operation failed, and the\n"
+				  "WARNING: attempt to rename them back to their\n"
+				  "WARNING: original names also failed.\n"
+				  "WARNING: Please rename them in %s manually:\n"), packdir);
 			for (i = 0; i < rollback_failure.nr; i++)
 				fprintf(stderr, "WARNING:   old-%s -> %s\n",
 					rollback_failure.items[i].string,
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 12/16] parse-options: replace opterror() with optname()
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (10 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
                       ` (3 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Introduce optname() that does the early half of original opterror() to
come up with the name of the option reported back to the user, and use
it to kill opterror().  The callers of opterror() now directly call
error() using the string returned by opterror() instead.

There are a few issues with opterror()

- it tries to assemble an English sentence from pieces. This is not
  great for translators because we give them pieces instead of a full
  sentence.

- It's a wrapper around error() and needs some hack to let the
  compiler know it always returns -1.

- Since it takes a string instead of printf format, one call site has
  to assemble the string manually before passing to it.

Using error() directly solves the second and third problems.

It kind helps the first problem as well because "%s does foo" does
give a translator a full sentence in a sense and let them reorder if
needed. But it has limitations, if the subject part has to change
based on the rest of the sentence, that language is screwed. This is
also why I try to avoid calling optname() when 'flags' is known in
advance.

Mark of these strings for translation as well while at there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge.c     |  2 +-
 builtin/revert.c    |  3 ++-
 parse-options-cb.c  |  7 ++++---
 parse-options.c     | 46 +++++++++++++++++++++++++--------------------
 parse-options.h     |  5 +----
 ref-filter.c        |  8 +++++---
 t/t4211-line-log.sh |  2 +-
 7 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 92ba7e1c6d..82248d43c3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -128,7 +128,7 @@ static int option_read_message(struct parse_opt_ctx_t *ctx,
 		ctx->argc--;
 		arg = *++ctx->argv;
 	} else
-		return opterror(opt, "requires a value", 0);
+		return error(_("option `%s' requires a value"), opt->long_name);
 
 	if (buf->len)
 		strbuf_addch(buf, '\n');
diff --git a/builtin/revert.c b/builtin/revert.c
index c93393c89b..11190d2ab4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -69,7 +69,8 @@ static int option_parse_m(const struct option *opt,
 
 	replay->mainline = strtol(arg, &end, 10);
 	if (*end || replay->mainline <= 0)
-		return opterror(opt, "expects a number greater than zero", 0);
+		return error(_("option `%s' expects a number greater than zero"),
+			     opt->long_name);
 
 	return 0;
 }
diff --git a/parse-options-cb.c b/parse-options-cb.c
index e8236534ac..813eb6301b 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -18,7 +18,8 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
 	} else {
 		v = strtol(arg, (char **)&arg, 10);
 		if (*arg)
-			return opterror(opt, "expects a numerical value", 0);
+			return error(_("option `%s' expects a numerical value"),
+				     opt->long_name);
 		if (v && v < MINIMUM_ABBREV)
 			v = MINIMUM_ABBREV;
 		else if (v > 40)
@@ -54,8 +55,8 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
 		arg = unset ? "never" : (const char *)opt->defval;
 	value = git_config_colorbool(NULL, arg);
 	if (value < 0)
-		return opterror(opt,
-			"expects \"always\", \"auto\", or \"never\"", 0);
+		return error(_("option `%s' expects \"always\", \"auto\", or \"never\""),
+			     opt->long_name);
 	*(int *)opt->value = value;
 	return 0;
 }
diff --git a/parse-options.c b/parse-options.c
index 3b874a83a0..0bf817193d 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -32,7 +32,7 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
 		p->argc--;
 		*arg = *++p->argv;
 	} else
-		return opterror(opt, "requires a value", flags);
+		return error(_("%s requires a value"), optname(opt, flags));
 	return 0;
 }
 
@@ -49,7 +49,6 @@ static int opt_command_mode_error(const struct option *opt,
 				  int flags)
 {
 	const struct option *that;
-	struct strbuf message = STRBUF_INIT;
 	struct strbuf that_name = STRBUF_INIT;
 
 	/*
@@ -67,13 +66,13 @@ static int opt_command_mode_error(const struct option *opt,
 			strbuf_addf(&that_name, "--%s", that->long_name);
 		else
 			strbuf_addf(&that_name, "-%c", that->short_name);
-		strbuf_addf(&message, ": incompatible with %s", that_name.buf);
+		error(_("%s is incompatible with %s"),
+		      optname(opt, flags), that_name.buf);
 		strbuf_release(&that_name);
-		opterror(opt, message.buf, flags);
-		strbuf_release(&message);
 		return -1;
 	}
-	return opterror(opt, ": incompatible with something else", flags);
+	return error(_("%s : incompatible with something else"),
+		     optname(opt, flags));
 }
 
 static int get_value(struct parse_opt_ctx_t *p,
@@ -86,11 +85,11 @@ static int get_value(struct parse_opt_ctx_t *p,
 	int err;
 
 	if (unset && p->opt)
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 	if (unset && (opt->flags & PARSE_OPT_NONEG))
-		return opterror(opt, "isn't available", flags);
+		return error(_("%s isn't available"), optname(opt, flags));
 	if (!(flags & OPT_SHORT) && p->opt && (opt->flags & PARSE_OPT_NOARG))
-		return opterror(opt, "takes no value", flags);
+		return error(_("%s takes no value"), optname(opt, flags));
 
 	switch (opt->type) {
 	case OPTION_LOWLEVEL_CALLBACK:
@@ -176,7 +175,8 @@ static int get_value(struct parse_opt_ctx_t *p,
 			return -1;
 		*(int *)opt->value = strtol(arg, (char **)&s, 10);
 		if (*s)
-			return opterror(opt, "expects a numerical value", flags);
+			return error(_("%s expects a numerical value"),
+				     optname(opt, flags));
 		return 0;
 
 	case OPTION_MAGNITUDE:
@@ -191,9 +191,9 @@ static int get_value(struct parse_opt_ctx_t *p,
 		if (get_arg(p, opt, flags, &arg))
 			return -1;
 		if (!git_parse_ulong(arg, opt->value))
-			return opterror(opt,
-				"expects a non-negative integer value with an optional k/m/g suffix",
-				flags);
+			return error(_("%s expects a non-negative integer value"
+				       " with an optional k/m/g suffix"),
+				     optname(opt, flags));
 		return 0;
 
 	default:
@@ -257,7 +257,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 			if (!rest)
 				continue;
 			if (*rest == '=')
-				return opterror(options, "takes no value", flags);
+				return error(_("%s takes no value"),
+					     optname(options, flags));
 			if (*rest)
 				continue;
 			p->out[p->cpidx++] = arg - 2;
@@ -773,12 +774,17 @@ void NORETURN usage_msg_opt(const char *msg,
 	usage_with_options(usagestr, options);
 }
 
-#undef opterror
-int opterror(const struct option *opt, const char *reason, int flags)
+const char *optname(const struct option *opt, int flags)
 {
+	static struct strbuf sb = STRBUF_INIT;
+
+	strbuf_reset(&sb);
 	if (flags & OPT_SHORT)
-		return error("switch `%c' %s", opt->short_name, reason);
-	if (flags & OPT_UNSET)
-		return error("option `no-%s' %s", opt->long_name, reason);
-	return error("option `%s' %s", opt->long_name, reason);
+		strbuf_addf(&sb, "switch `%c'", opt->short_name);
+	else if (flags & OPT_UNSET)
+		strbuf_addf(&sb, "option `no-%s'", opt->long_name);
+	else
+		strbuf_addf(&sb, "option `%s'", opt->long_name);
+
+	return sb.buf;
 }
diff --git a/parse-options.h b/parse-options.h
index dd14911a29..2e146aa6fa 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -189,10 +189,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
 				   const struct option *options);
 
 extern int optbug(const struct option *opt, const char *reason);
-extern int opterror(const struct option *opt, const char *reason, int flags);
-#if defined(__GNUC__)
-#define opterror(o,r,f) (opterror((o),(r),(f)), const_error())
-#endif
+const char *optname(const struct option *opt, int flags);
 
 /*----- incremental advanced APIs -----*/
 
diff --git a/ref-filter.c b/ref-filter.c
index 2a05619211..0681359100 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2302,9 +2302,11 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 
 	if (rf->merge) {
 		if (no_merged) {
-			return opterror(opt, "is incompatible with --merged", 0);
+			return error(_("option `%s' is incompatible with --merged"),
+				     opt->long_name);
 		} else {
-			return opterror(opt, "is incompatible with --no-merged", 0);
+			return error(_("option `%s' is incompatible with --no-merged"),
+				     opt->long_name);
 		}
 	}
 
@@ -2318,7 +2320,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
 	rf->merge_commit = lookup_commit_reference_gently(the_repository,
 							  &oid, 0);
 	if (!rf->merge_commit)
-		return opterror(opt, "must point to a commit", 0);
+		return error(_("option `%s' must point to a commit"), opt->long_name);
 
 	return 0;
 }
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
index ef1322148e..bd5fe4d148 100755
--- a/t/t4211-line-log.sh
+++ b/t/t4211-line-log.sh
@@ -25,7 +25,7 @@ canned_test_failure () {
 test_bad_opts () {
 	test_expect_success "invalid args: $1" "
 		test_must_fail git log $1 2>errors &&
-		grep '$2' errors
+		test_i18ngrep '$2' errors
 	"
 }
 
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 13/16] parse-options.c: turn some die() to BUG()
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (11 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
                       ` (2 subsequent siblings)
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

These two strings are clearly not for the user to see. Reduce the
violence in one string while at there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 0bf817193d..3f5f985c1e 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -197,7 +197,7 @@ static int get_value(struct parse_opt_ctx_t *p,
 		return 0;
 
 	default:
-		die("should not happen, someone must be hit on the forehead");
+		BUG("opt->type %d should not happen", opt->type);
 	}
 }
 
@@ -424,7 +424,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
 	ctx->flags = flags;
 	if ((flags & PARSE_OPT_KEEP_UNKNOWN) &&
 	    (flags & PARSE_OPT_STOP_AT_NON_OPTION))
-		die("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
+		BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together");
 	parse_options_check(options);
 }
 
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 14/16] parse-options.c: mark more strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (12 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

One error is updated to start with lowercase to be consistent with the
rest.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options.c          | 14 +++++++-------
 t/t0040-parse-options.sh |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 3f5f985c1e..86aad2e185 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -319,8 +319,8 @@ static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
 	}
 
 	if (ambiguous_option) {
-		error("Ambiguous option: %s "
-			"(could be --%s%s or --%s%s)",
+		error(_("ambiguous option: %s "
+			"(could be --%s%s or --%s%s)"),
 			arg,
 			(ambiguous_flags & OPT_UNSET) ?  "no-" : "",
 			ambiguous_option->long_name,
@@ -353,7 +353,7 @@ static void check_typos(const char *arg, const struct option *options)
 		return;
 
 	if (starts_with(arg, "no-")) {
-		error ("did you mean `--%s` (with two dashes ?)", arg);
+		error(_("did you mean `--%s` (with two dashes ?)"), arg);
 		exit(129);
 	}
 
@@ -361,7 +361,7 @@ static void check_typos(const char *arg, const struct option *options)
 		if (!options->long_name)
 			continue;
 		if (starts_with(options->long_name, arg)) {
-			error ("did you mean `--%s` (with two dashes ?)", arg);
+			error(_("did you mean `--%s` (with two dashes ?)"), arg);
 			exit(129);
 		}
 	}
@@ -644,11 +644,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
 		break;
 	default: /* PARSE_OPT_UNKNOWN */
 		if (ctx.argv[0][1] == '-') {
-			error("unknown option `%s'", ctx.argv[0] + 2);
+			error(_("unknown option `%s'"), ctx.argv[0] + 2);
 		} else if (isascii(*ctx.opt)) {
-			error("unknown switch `%c'", *ctx.opt);
+			error(_("unknown switch `%c'"), *ctx.opt);
 		} else {
-			error("unknown non-ascii option in string: `%s'",
+			error(_("unknown non-ascii option in string: `%s'"),
 			      ctx.argv[0]);
 		}
 		usage_with_options(usagestr, options);
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 17d0c18feb..e46b1e02f0 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -228,7 +228,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -boolean >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 cat >typo.err <<\EOF
@@ -238,7 +238,7 @@ EOF
 test_expect_success 'detect possible typos' '
 	test_must_fail test-tool parse-options -ambiguous >output 2>output.err &&
 	test_must_be_empty output &&
-	test_cmp typo.err output.err
+	test_i18ncmp typo.err output.err
 '
 
 test_expect_success 'keep some options as arguments' '
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 15/16] fsck: reduce word legos to help i18n
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (13 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  2018-11-10  5:16     ` [PATCH v3 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

These messages will be marked for translation later. Reduce word legos
and give translators almost full phrases. describe_object() is updated
so that it can be called from printf() twice.

While at there, remove \n from the strings to reduce a bit of work
from translators.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c | 65 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 25 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 06eb421720..1feb6142f4 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -52,16 +52,24 @@ static int name_objects;
 
 static const char *describe_object(struct object *obj)
 {
-	static struct strbuf buf = STRBUF_INIT;
-	char *name = name_objects ?
-		lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
+	static struct strbuf bufs[] = {
+		STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
+	};
+	static int b = 0;
+	struct strbuf *buf;
+	char *name = NULL;
 
-	strbuf_reset(&buf);
-	strbuf_addstr(&buf, oid_to_hex(&obj->oid));
+	if (name_objects)
+		name = lookup_decoration(fsck_walk_options.object_names, obj);
+
+	buf = bufs + b;
+	b = (b + 1) % ARRAY_SIZE(bufs);
+	strbuf_reset(buf);
+	strbuf_addstr(buf, oid_to_hex(&obj->oid));
 	if (name)
-		strbuf_addf(&buf, " (%s)", name);
+		strbuf_addf(buf, " (%s)", name);
 
-	return buf.buf;
+	return buf->buf;
 }
 
 static const char *printable_type(struct object *obj)
@@ -105,25 +113,29 @@ static int fsck_config(const char *var, const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }
 
-static void objreport(struct object *obj, const char *msg_type,
-			const char *err)
-{
-	fprintf(stderr, "%s in %s %s: %s\n",
-		msg_type, printable_type(obj), describe_object(obj), err);
-}
-
 static int objerror(struct object *obj, const char *err)
 {
 	errors_found |= ERROR_OBJECT;
-	objreport(obj, "error", err);
+	fprintf_ln(stderr, "error in %s %s: %s",
+		   printable_type(obj), describe_object(obj), err);
 	return -1;
 }
 
 static int fsck_error_func(struct fsck_options *o,
 	struct object *obj, int type, const char *message)
 {
-	objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
-	return (type == FSCK_WARN) ? 0 : 1;
+	switch (type) {
+	case FSCK_WARN:
+		fprintf_ln(stderr, "warning in %s %s: %s",
+			   printable_type(obj), describe_object(obj), message);
+		return 0;
+	case FSCK_ERROR:
+		fprintf_ln(stderr, "error in %s %s: %s",
+			   printable_type(obj), describe_object(obj), message);
+		return 1;
+	default:
+		BUG("%d (FSCK_IGNORE?) should never trigger this callback", type);
+	}
 }
 
 static struct object_array pending;
@@ -165,10 +177,12 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
-			printf("broken link from %7s %s\n",
-				 printable_type(parent), describe_object(parent));
-			printf("              to %7s %s\n",
-				 printable_type(obj), describe_object(obj));
+			printf_ln("broken link from %7s %s\n"
+				  "              to %7s %s",
+				  printable_type(parent),
+				  describe_object(parent),
+				  printable_type(obj),
+				  describe_object(obj));
 			errors_found |= ERROR_REACHABLE;
 		}
 		return 1;
@@ -371,10 +385,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 		struct tag *tag = (struct tag *) obj;
 
 		if (show_tags && tag->tagged) {
-			printf("tagged %s %s", printable_type(tag->tagged),
-				describe_object(tag->tagged));
-			printf(" (%s) in %s\n", tag->tag,
-				describe_object(&tag->object));
+			printf_ln("tagged %s %s (%s) in %s",
+				  printable_type(tag->tagged),
+				  describe_object(tag->tagged),
+				  tag->tag,
+				  describe_object(&tag->object));
 		}
 	}
 
-- 
2.19.1.1231.g84aef82467


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

* [PATCH v3 16/16] fsck: mark strings for translation
  2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
                       ` (14 preceding siblings ...)
  2018-11-10  5:16     ` [PATCH v3 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
@ 2018-11-10  5:16     ` Nguyễn Thái Ngọc Duy
  15 siblings, 0 replies; 71+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-11-10  5:16 UTC (permalink / raw)
  To: pclouds; +Cc: git, gitster, szeder.dev

Two die() are updated to start with lowercase to be consistent with
the rest.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fsck.c             | 106 ++++++++++++++++++++-----------------
 t/t1410-reflog.sh          |   6 +--
 t/t1450-fsck.sh            |  50 ++++++++---------
 t/t6050-replace.sh         |   4 +-
 t/t7415-submodule-names.sh |   6 +--
 5 files changed, 90 insertions(+), 82 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 1feb6142f4..dcf72859a6 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -85,7 +85,7 @@ static const char *printable_type(struct object *obj)
 
 	ret = type_name(obj->type);
 	if (!ret)
-		ret = "unknown";
+		ret = _("unknown");
 
 	return ret;
 }
@@ -116,7 +116,8 @@ static int fsck_config(const char *var, const char *value, void *cb)
 static int objerror(struct object *obj, const char *err)
 {
 	errors_found |= ERROR_OBJECT;
-	fprintf_ln(stderr, "error in %s %s: %s",
+	/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
+	fprintf_ln(stderr, _("error in %s %s: %s"),
 		   printable_type(obj), describe_object(obj), err);
 	return -1;
 }
@@ -126,11 +127,13 @@ static int fsck_error_func(struct fsck_options *o,
 {
 	switch (type) {
 	case FSCK_WARN:
-		fprintf_ln(stderr, "warning in %s %s: %s",
+		/* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
+		fprintf_ln(stderr, _("warning in %s %s: %s"),
 			   printable_type(obj), describe_object(obj), message);
 		return 0;
 	case FSCK_ERROR:
-		fprintf_ln(stderr, "error in %s %s: %s",
+		/* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
+		fprintf_ln(stderr, _("error in %s %s: %s"),
 			   printable_type(obj), describe_object(obj), message);
 		return 1;
 	default:
@@ -151,17 +154,18 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 	 */
 	if (!obj) {
 		/* ... these references to parent->fld are safe here */
-		printf("broken link from %7s %s\n",
-			   printable_type(parent), describe_object(parent));
-		printf("broken link from %7s %s\n",
-			   (type == OBJ_ANY ? "unknown" : type_name(type)), "unknown");
+		printf_ln(_("broken link from %7s %s"),
+			  printable_type(parent), describe_object(parent));
+		printf_ln(_("broken link from %7s %s"),
+			  (type == OBJ_ANY ? _("unknown") : type_name(type)),
+			  _("unknown"));
 		errors_found |= ERROR_REACHABLE;
 		return 1;
 	}
 
 	if (type != OBJ_ANY && obj->type != type)
 		/* ... and the reference to parent is safe here */
-		objerror(parent, "wrong object type in link");
+		objerror(parent, _("wrong object type in link"));
 
 	if (obj->flags & REACHABLE)
 		return 0;
@@ -177,8 +181,8 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
 
 	if (!(obj->flags & HAS_OBJ)) {
 		if (parent && !has_object_file(&obj->oid)) {
-			printf_ln("broken link from %7s %s\n"
-				  "              to %7s %s",
+			printf_ln(_("broken link from %7s %s\n"
+				    "              to %7s %s"),
 				  printable_type(parent),
 				  describe_object(parent),
 				  printable_type(obj),
@@ -246,8 +250,8 @@ static void check_reachable_object(struct object *obj)
 			return;
 		if (has_object_pack(&obj->oid))
 			return; /* it is in pack - forget about it */
-		printf("missing %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("missing %s %s"), printable_type(obj),
+			  describe_object(obj));
 		errors_found |= ERROR_REACHABLE;
 		return;
 	}
@@ -272,8 +276,8 @@ static void check_unreachable_object(struct object *obj)
 	 * since this is something that is prunable.
 	 */
 	if (show_unreachable) {
-		printf("unreachable %s %s\n", printable_type(obj),
-			describe_object(obj));
+		printf_ln(_("unreachable %s %s"), printable_type(obj),
+			  describe_object(obj));
 		return;
 	}
 
@@ -291,8 +295,8 @@ static void check_unreachable_object(struct object *obj)
 	 */
 	if (!(obj->flags & USED)) {
 		if (show_dangling)
-			printf("dangling %s %s\n", printable_type(obj),
-			       describe_object(obj));
+			printf_ln(_("dangling %s %s"), printable_type(obj),
+				  describe_object(obj));
 		if (write_lost_and_found) {
 			char *filename = git_pathdup("lost-found/%s/%s",
 				obj->type == OBJ_COMMIT ? "commit" : "other",
@@ -300,18 +304,18 @@ static void check_unreachable_object(struct object *obj)
 			FILE *f;
 
 			if (safe_create_leading_directories_const(filename)) {
-				error("Could not create lost-found");
+				error(_("could not create lost-found"));
 				free(filename);
 				return;
 			}
 			f = xfopen(filename, "w");
 			if (obj->type == OBJ_BLOB) {
 				if (stream_blob_to_fd(fileno(f), &obj->oid, NULL, 1))
-					die_errno("Could not write '%s'", filename);
+					die_errno(_("could not write '%s'"), filename);
 			} else
 				fprintf(f, "%s\n", describe_object(obj));
 			if (fclose(f))
-				die_errno("Could not finish '%s'",
+				die_errno(_("could not finish '%s'"),
 					  filename);
 			free(filename);
 		}
@@ -328,7 +332,7 @@ static void check_unreachable_object(struct object *obj)
 static void check_object(struct object *obj)
 {
 	if (verbose)
-		fprintf(stderr, "Checking %s\n", describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s"), describe_object(obj));
 
 	if (obj->flags & REACHABLE)
 		check_reachable_object(obj);
@@ -346,7 +350,7 @@ static void check_connectivity(void)
 	/* Look up all the requirements, warn about missing objects.. */
 	max = get_max_object_index();
 	if (verbose)
-		fprintf(stderr, "Checking connectivity (%d objects)\n", max);
+		fprintf_ln(stderr, _("Checking connectivity (%d objects)"), max);
 
 	for (i = 0; i < max; i++) {
 		struct object *obj = get_indexed_object(i);
@@ -365,11 +369,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 	obj->flags |= SEEN;
 
 	if (verbose)
-		fprintf(stderr, "Checking %s %s\n",
-			printable_type(obj), describe_object(obj));
+		fprintf_ln(stderr, _("Checking %s %s"),
+			   printable_type(obj), describe_object(obj));
 
 	if (fsck_walk(obj, NULL, &fsck_obj_options))
-		objerror(obj, "broken links");
+		objerror(obj, _("broken links"));
 	err = fsck_object(obj, buffer, size, &fsck_obj_options);
 	if (err)
 		goto out;
@@ -378,14 +382,15 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
 		struct commit *commit = (struct commit *) obj;
 
 		if (!commit->parents && show_root)
-			printf("root %s\n", describe_object(&commit->object));
+			printf_ln(_("root %s"),
+				  describe_object(&commit->object));
 	}
 
 	if (obj->type == OBJ_TAG) {
 		struct tag *tag = (struct tag *) obj;
 
 		if (show_tags && tag->tagged) {
-			printf_ln("tagged %s %s (%s) in %s",
+			printf_ln(_("tagged %s %s (%s) in %s"),
 				  printable_type(tag->tagged),
 				  describe_object(tag->tagged),
 				  tag->tag,
@@ -413,7 +418,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
 				  eaten);
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		return error("%s: object corrupt or missing", oid_to_hex(oid));
+		return error(_("%s: object corrupt or missing"),
+			     oid_to_hex(oid));
 	}
 	obj->flags &= ~(REACHABLE | SEEN);
 	obj->flags |= HAS_OBJ;
@@ -437,7 +443,8 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
 			obj->flags |= USED;
 			mark_object_reachable(obj);
 		} else if (!is_promisor_object(oid)) {
-			error("%s: invalid reflog entry %s", refname, oid_to_hex(oid));
+			error(_("%s: invalid reflog entry %s"),
+			      refname, oid_to_hex(oid));
 			errors_found |= ERROR_REACHABLE;
 		}
 	}
@@ -450,8 +457,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
 	const char *refname = cb_data;
 
 	if (verbose)
-		fprintf(stderr, "Checking reflog %s->%s\n",
-			oid_to_hex(ooid), oid_to_hex(noid));
+		fprintf_ln(stderr, _("Checking reflog %s->%s"),
+			   oid_to_hex(ooid), oid_to_hex(noid));
 
 	fsck_handle_reflog_oid(refname, ooid, 0);
 	fsck_handle_reflog_oid(refname, noid, timestamp);
@@ -480,13 +487,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
 			 default_refs++;
 			 return 0;
 		}
-		error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid));
+		error(_("%s: invalid sha1 pointer %s"),
+		      refname, oid_to_hex(oid));
 		errors_found |= ERROR_REACHABLE;
 		/* We'll continue with the rest despite the error.. */
 		return 0;
 	}
 	if (obj->type != OBJ_COMMIT && is_branch(refname)) {
-		error("%s: not a commit", refname);
+		error(_("%s: not a commit"), refname);
 		errors_found |= ERROR_REFS;
 	}
 	default_refs++;
@@ -520,7 +528,7 @@ static void get_default_heads(void)
 	 * "show_unreachable" flag.
 	 */
 	if (!default_refs) {
-		fprintf(stderr, "notice: No default references\n");
+		fprintf_ln(stderr, _("notice: No default references"));
 		show_unreachable = 0;
 	}
 }
@@ -535,7 +543,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (read_loose_object(path, oid, &type, &size, &contents) < 0) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object corrupt or missing: %s",
+		error(_("%s: object corrupt or missing: %s"),
 		      oid_to_hex(oid), path);
 		return 0; /* keep checking other objects */
 	}
@@ -548,7 +556,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 
 	if (!obj) {
 		errors_found |= ERROR_OBJECT;
-		error("%s: object could not be parsed: %s",
+		error(_("%s: object could not be parsed: %s"),
 		      oid_to_hex(oid), path);
 		if (!eaten)
 			free(contents);
@@ -568,7 +576,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
 static int fsck_cruft(const char *basename, const char *path, void *data)
 {
 	if (!starts_with(basename, "tmp_obj_"))
-		fprintf(stderr, "bad sha1 file: %s\n", path);
+		fprintf_ln(stderr, _("bad sha1 file: %s"), path);
 	return 0;
 }
 
@@ -583,7 +591,7 @@ static void fsck_object_dir(const char *path)
 	struct progress *progress = NULL;
 
 	if (verbose)
-		fprintf(stderr, "Checking object directory\n");
+		fprintf_ln(stderr, _("Checking object directory"));
 
 	if (show_progress)
 		progress = start_progress(_("Checking object directories"), 256);
@@ -599,28 +607,28 @@ static int fsck_head_link(void)
 	int null_is_error = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking HEAD link\n");
+		fprintf_ln(stderr, _("Checking HEAD link"));
 
 	head_points_at = resolve_ref_unsafe("HEAD", 0, &head_oid, NULL);
 	if (!head_points_at) {
 		errors_found |= ERROR_REFS;
-		return error("Invalid HEAD");
+		return error(_("invalid HEAD"));
 	}
 	if (!strcmp(head_points_at, "HEAD"))
 		/* detached HEAD */
 		null_is_error = 1;
 	else if (!starts_with(head_points_at, "refs/heads/")) {
 		errors_found |= ERROR_REFS;
-		return error("HEAD points to something strange (%s)",
+		return error(_("HEAD points to something strange (%s)"),
 			     head_points_at);
 	}
 	if (is_null_oid(&head_oid)) {
 		if (null_is_error) {
 			errors_found |= ERROR_REFS;
-			return error("HEAD: detached HEAD points at nothing");
+			return error(_("HEAD: detached HEAD points at nothing"));
 		}
-		fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
-			head_points_at + 11);
+		fprintf_ln(stderr, _("notice: HEAD points to an unborn branch (%s)"),
+			   head_points_at + 11);
 	}
 	return 0;
 }
@@ -631,12 +639,12 @@ static int fsck_cache_tree(struct cache_tree *it)
 	int err = 0;
 
 	if (verbose)
-		fprintf(stderr, "Checking cache tree\n");
+		fprintf_ln(stderr, _("Checking cache tree"));
 
 	if (0 <= it->entry_count) {
 		struct object *obj = parse_object(the_repository, &it->oid);
 		if (!obj) {
-			error("%s: invalid sha1 pointer in cache-tree",
+			error(_("%s: invalid sha1 pointer in cache-tree"),
 			      oid_to_hex(&it->oid));
 			errors_found |= ERROR_REFS;
 			return 1;
@@ -647,7 +655,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 				obj, xstrdup(":"));
 		mark_object_reachable(obj);
 		if (obj->type != OBJ_TREE)
-			err |= objerror(obj, "non-tree in cache-tree");
+			err |= objerror(obj, _("non-tree in cache-tree"));
 	}
 	for (i = 0; i < it->subtree_nr; i++)
 		err |= fsck_cache_tree(it->down[i]->cache_tree);
@@ -789,7 +797,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			if (!obj || !(obj->flags & HAS_OBJ)) {
 				if (is_promisor_object(&oid))
 					continue;
-				error("%s: object missing", oid_to_hex(&oid));
+				error(_("%s: object missing"), oid_to_hex(&oid));
 				errors_found |= ERROR_OBJECT;
 				continue;
 			}
@@ -801,7 +809,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 			mark_object_reachable(obj);
 			continue;
 		}
-		error("invalid parameter: expected sha1, got '%s'", arg);
+		error(_("invalid parameter: expected sha1, got '%s'"), arg);
 		errors_found |= ERROR_OBJECT;
 	}
 
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 388b0611d8..353bdfd415 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -20,12 +20,12 @@ check_have () {
 }
 
 check_fsck () {
-	output=$(git fsck --full)
+	git fsck --full >fsck.output
 	case "$1" in
 	'')
-		test -z "$output" ;;
+		test_must_be_empty fsck.output ;;
 	*)
-		echo "$output" | grep "$1" ;;
+		test_i18ngrep "$1" fsck.output ;;
 	esac
 }
 
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 90c765df3a..15ca98b2a9 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -70,7 +70,7 @@ test_expect_success 'object with bad sha1' '
 
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "$sha.*corrupt" out
+	test_i18ngrep "$sha.*corrupt" out
 '
 
 test_expect_success 'branch pointing to non-commit' '
@@ -78,7 +78,7 @@ test_expect_success 'branch pointing to non-commit' '
 	test_when_finished "git update-ref -d refs/heads/invalid" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "not a commit" out
+	test_i18ngrep "not a commit" out
 '
 
 test_expect_success 'HEAD link pointing at a funny object' '
@@ -88,7 +88,7 @@ test_expect_success 'HEAD link pointing at a funny object' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "detached HEAD points" out
+	test_i18ngrep "detached HEAD points" out
 '
 
 test_expect_success 'HEAD link pointing at a funny place' '
@@ -98,7 +98,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
 	# avoid corrupt/broken HEAD from interfering with repo discovery
 	test_must_fail env GIT_DIR=.git git fsck 2>out &&
 	cat out &&
-	grep "HEAD points to something strange" out
+	test_i18ngrep "HEAD points to something strange" out
 '
 
 test_expect_success 'email without @ is okay' '
@@ -122,7 +122,7 @@ test_expect_success 'email with embedded > is not okay' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 test_expect_success 'missing < email delimiter is reported nicely' '
@@ -134,7 +134,7 @@ test_expect_success 'missing < email delimiter is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - bad name" out
+	test_i18ngrep "error in commit $new.* - bad name" out
 '
 
 test_expect_success 'missing email is reported nicely' '
@@ -146,7 +146,7 @@ test_expect_success 'missing email is reported nicely' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.* - missing email" out
+	test_i18ngrep "error in commit $new.* - missing email" out
 '
 
 test_expect_success '> in name is reported' '
@@ -158,7 +158,7 @@ test_expect_success '> in name is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new" out
+	test_i18ngrep "error in commit $new" out
 '
 
 # date is 2^64 + 1
@@ -172,7 +172,7 @@ test_expect_success 'integer overflow in timestamps is reported' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*integer overflow" out
+	test_i18ngrep "error in commit $new.*integer overflow" out
 '
 
 test_expect_success 'commit with NUL in header' '
@@ -184,7 +184,7 @@ test_expect_success 'commit with NUL in header' '
 	test_when_finished "git update-ref -d refs/heads/bogus" &&
 	test_must_fail git fsck 2>out &&
 	cat out &&
-	grep "error in commit $new.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'tree object with duplicate entries' '
@@ -205,7 +205,7 @@ test_expect_success 'tree object with duplicate entries' '
 		git hash-object -w -t tree --stdin
 	) &&
 	test_must_fail git fsck 2>out &&
-	grep "error in tree .*contains duplicate file entries" out
+	test_i18ngrep "error in tree .*contains duplicate file entries" out
 '
 
 test_expect_success 'unparseable tree object' '
@@ -259,7 +259,7 @@ test_expect_success 'tag pointing to nonexistent' '
 	test_when_finished "git update-ref -d refs/tags/invalid" &&
 	test_must_fail git fsck --tags >out &&
 	cat out &&
-	grep "broken link" out
+	test_i18ngrep "broken link" out
 '
 
 test_expect_success 'tag pointing to something else than its type' '
@@ -301,7 +301,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' '
 	warning in tag $tag: badTagName: invalid '\''tag'\'' name: wrong name format
 	warning in tag $tag: missingTaggerEntry: invalid format - expected '\''tagger'\'' line
 	EOF
-	test_cmp expect out
+	test_i18ncmp expect out
 '
 
 test_expect_success 'tag with bad tagger' '
@@ -320,7 +320,7 @@ test_expect_success 'tag with bad tagger' '
 	echo $tag >.git/refs/tags/wrong &&
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
-	grep "error in tag .*: invalid author/committer" out
+	test_i18ngrep "error in tag .*: invalid author/committer" out
 '
 
 test_expect_success 'tag with NUL in header' '
@@ -340,7 +340,7 @@ test_expect_success 'tag with NUL in header' '
 	test_when_finished "git update-ref -d refs/tags/wrong" &&
 	test_must_fail git fsck --tags 2>out &&
 	cat out &&
-	grep "error in tag $tag.*unterminated header: NUL at offset" out
+	test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out
 '
 
 test_expect_success 'cleaned up' '
@@ -396,7 +396,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -407,7 +407,7 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
 	       git hash-object -w --stdin -t tree) &&
 	  git fsck 2>out &&
 	  cat out &&
-	  grep "warning.*null sha1" out
+	  test_i18ngrep "warning.*null sha1" out
 	)
 '
 
@@ -428,7 +428,7 @@ while read name path pretty; do
 			bad_tree=$(git mktree <bad) &&
 			git fsck 2>out &&
 			cat out &&
-			grep "warning.*tree $bad_tree" out
+			test_i18ngrep "warning.*tree $bad_tree" out
 		)'
 	done <<-\EOF
 	100644 blob
@@ -474,9 +474,9 @@ test_expect_success 'NUL in commit' '
 		git branch bad $(cat name) &&
 
 		test_must_fail git -c fsck.nulInCommit=error fsck 2>warn.1 &&
-		grep nulInCommit warn.1 &&
+		test_i18ngrep nulInCommit warn.1 &&
 		git fsck 2>warn.2 &&
-		grep nulInCommit warn.2
+		test_i18ngrep nulInCommit warn.2
 	)
 '
 
@@ -594,7 +594,7 @@ test_expect_success 'fsck --name-objects' '
 		remove_object $(git rev-parse julius:caesar.t) &&
 		test_must_fail git fsck --name-objects >out &&
 		tree=$(git rev-parse --verify julius:) &&
-		egrep "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
+		test_i18ngrep -E "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
 	)
 '
 
@@ -605,7 +605,7 @@ test_expect_success 'alternate objects are correctly blamed' '
 	mkdir alt.git/objects/12 &&
 	>alt.git/objects/12/34567890123456789012345678901234567890 &&
 	test_must_fail git fsck >out 2>&1 &&
-	grep alt.git out
+	test_i18ngrep alt.git out
 '
 
 test_expect_success 'fsck errors in packed objects' '
@@ -624,8 +624,8 @@ test_expect_success 'fsck errors in packed objects' '
 	remove_object $one &&
 	remove_object $two &&
 	test_must_fail git fsck 2>out &&
-	grep "error in commit $one.* - bad name" out &&
-	grep "error in commit $two.* - bad name" out &&
+	test_i18ngrep "error in commit $one.* - bad name" out &&
+	test_i18ngrep "error in commit $two.* - bad name" out &&
 	! grep corrupt out
 '
 
@@ -706,7 +706,7 @@ test_expect_success 'fsck notices dangling objects' '
 		git fsck >actual &&
 		# the output order is non-deterministic, as it comes from a hash
 		sort <actual >actual.sorted &&
-		test_cmp expect actual.sorted
+		test_i18ncmp expect actual.sorted
 	)
 '
 
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 86374a9c52..7700a8e793 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -133,8 +133,8 @@ test_expect_success 'tag replaced commit' '
 
 test_expect_success '"git fsck" works' '
      git fsck master >fsck_master.out &&
-     grep "dangling commit $R" fsck_master.out &&
-     grep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
+     test_i18ngrep "dangling commit $R" fsck_master.out &&
+     test_i18ngrep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
      test -z "$(git fsck)"
 '
 
diff --git a/t/t7415-submodule-names.sh b/t/t7415-submodule-names.sh
index 293e2e1963..49a37efe9c 100755
--- a/t/t7415-submodule-names.sh
+++ b/t/t7415-submodule-names.sh
@@ -154,7 +154,7 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
 		# symlink detector; this grep string comes from the config
 		# variable name and will not be translated.
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesSymlink output
+		test_i18ngrep gitmodulesSymlink output
 	)
 '
 
@@ -172,7 +172,7 @@ test_expect_success 'fsck detects non-blob .gitmodules' '
 		git ls-tree HEAD | sed s/subdir/.gitmodules/ | git mktree &&
 
 		test_must_fail git fsck 2>output &&
-		grep gitmodulesBlob output
+		test_i18ngrep gitmodulesBlob output
 	)
 '
 
@@ -186,7 +186,7 @@ test_expect_success 'fsck detects corrupt .gitmodules' '
 		git commit -m "broken gitmodules" &&
 
 		git fsck 2>output &&
-		grep gitmodulesParse output &&
+		test_i18ngrep gitmodulesParse output &&
 		test_i18ngrep ! "bad config" output
 	)
 '
-- 
2.19.1.1231.g84aef82467


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

* Re: [PATCH v2 12/16] parse-options: replace opterror() with optname()
  2018-11-10  4:55         ` Duy Nguyen
@ 2018-11-10 14:59           ` Ramsay Jones
  0 siblings, 0 replies; 71+ messages in thread
From: Ramsay Jones @ 2018-11-10 14:59 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Junio C Hamano, Git Mailing List, SZEDER Gábor



On 10/11/2018 04:55, Duy Nguyen wrote:
> On Tue, Nov 6, 2018 at 3:07 PM Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:
>> Also, this patch does not replace opterror() calls outside of
>> the 'parse-options.c' file with optname(). This tickles my
>> static-check.pl script, since optname() is an external function
>> which is only called from 'parse-options.c'.
>>
>> So, at present, optname() could be marked as a local 'static'
>> symbol. However, I could also imagine it being used by new callers
>> outside of 'parse-options.c' in the future. (maybe) Your call. ;-)
> 
> I was making it static, but the compiler complained about undefined
> function and I would need to either move optname() up in
> parse-options.c or add a forward declaration (but I was going to
> _remove_ the declaration!)
> 
> Since it could be potentially used by Jeff's series (and I think it
> does have potential in parse-options-cb.c), I'll just leave it
> exported and caress your static-check.pl script

Fair enough.

>                                                (how did it not catch
> optbug() not being used outside parse-options.c either)?

It did, some time ago (presumably, I haven't checked). Which is to
say: the output from the master branch notes it:

    $ grep parse-options sc
    parse-options.o	- optbug
    $ 

... but if it gets to the master branch I tend to forget it. (I have
been meaning to go through the 'sc' file and clean out some of the
'easy' cases).

So, if optname() doesn't get any new callers, I will watch it go
from 'pu' to 'next' and then to 'master' and ... ;-)

ATB,
Ramsay Jones

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

end of thread, other threads:[~2018-11-10 14:59 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-28  6:51 [PATCH 00/12] Mark more strings for translation Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 01/12] git.c: mark " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 02/12] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 03/12] archive.c: mark more " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 04/12] attr.c: mark more string " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 05/12] read-cache.c: mark more strings " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 06/12] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 07/12] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 08/12] remote.c: mark messages " Nguyễn Thái Ngọc Duy
2018-10-29  7:56   ` Junio C Hamano
2018-10-29 16:16     ` Duy Nguyen
2018-10-28  6:51 ` [PATCH 09/12] repack: mark more strings " Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 10/12] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 11/12] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
2018-10-28  6:51 ` [PATCH 12/12] fsck: mark " Nguyễn Thái Ngọc Duy
2018-10-29 10:53   ` SZEDER Gábor
2018-10-29 14:09     ` Junio C Hamano
2018-10-29 16:14       ` Duy Nguyen
2018-10-29 17:38         ` Ævar Arnfjörð Bjarmason
2018-10-29 17:43           ` Ævar Arnfjörð Bjarmason
2018-11-01  1:36             ` Jiang Xin
2018-10-30 23:27           ` Jonathan Nieder
2018-11-05 17:21     ` Duy Nguyen
2018-11-05 19:20 ` [PATCH v2 00/16] Mark more " Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
2018-11-06  2:02     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
2018-11-06  2:09     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
2018-11-06  2:10     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
2018-11-06  2:12     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
2018-11-06  2:13     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
2018-11-06  2:21     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
2018-11-06  2:33     ` Junio C Hamano
2018-11-06 14:02       ` Ramsay Jones
2018-11-06 19:08         ` Jeff King
2018-11-10  4:55         ` Duy Nguyen
2018-11-10 14:59           ` Ramsay Jones
2018-11-05 19:20   ` [PATCH v2 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
2018-11-06  3:27     ` Junio C Hamano
2018-11-05 19:20   ` [PATCH v2 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
2018-11-05 19:20   ` [PATCH v2 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
2018-11-06  3:41     ` Junio C Hamano
2018-11-10  4:59       ` Duy Nguyen
2018-11-05 19:20   ` [PATCH v2 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy
2018-11-10  5:15   ` [PATCH v3 00/16] Mark more " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 01/16] git.c: mark " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 02/16] alias.c: mark split_cmdline_strerror() " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 03/16] archive.c: mark more " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 04/16] attr.c: mark more string " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 05/16] read-cache.c: turn die("internal error") to BUG() Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 06/16] read-cache.c: mark more strings for translation Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 07/16] read-cache.c: add missing colon separators Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 08/16] reflog: mark strings for translation Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 09/16] remote.c: turn some error() or die() to BUG() Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 10/16] remote.c: mark messages for translation Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 11/16] repack: mark more strings " Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 12/16] parse-options: replace opterror() with optname() Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 13/16] parse-options.c: turn some die() to BUG() Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 14/16] parse-options.c: mark more strings for translation Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 15/16] fsck: reduce word legos to help i18n Nguyễn Thái Ngọc Duy
2018-11-10  5:16     ` [PATCH v3 16/16] fsck: mark strings for translation Nguyễn Thái Ngọc Duy

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).