All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 05/12] read-cache.c: mark more strings for translation
Date: Sun, 28 Oct 2018 07:51:50 +0100	[thread overview]
Message-ID: <20181028065157.26727-6-pclouds@gmail.com> (raw)
In-Reply-To: <20181028065157.26727-1-pclouds@gmail.com>

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


  parent reply	other threads:[~2018-10-28  6:52 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Nguyễn Thái Ngọc Duy [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181028065157.26727-6-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.