read-cache.c: mark more strings for translation

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Nov 10, 2018 at 06:16 UTC 9d0a9e9089639d9bdcd7f616121e0683bb3d6e3e
2 files changed +30 -29
read-cache.c
+29 -28
@@ -672,7 +672,8 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
672 struct cache_entry *new_entry;
673
674 if (alias->ce_flags & CE_ADDED)
675 - die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
675 + die(_("will not add file alias '%s' ('%s' already exists in index)"),
676 + ce->name, alias->name);
677
678 /* Ok, create the new entry using the name of the existing alias */
679 len = ce_namelen(alias);
@@ -687,7 +688,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
688 {
689 struct object_id oid;
690 if (write_object_file("", 0, blob_type, &oid))
690 - die("cannot create an empty blob in the object database");
691 + die(_("cannot create an empty blob in the object database"));
692 oidcpy(&ce->oid, &oid);
693 }
694
@@ -708,7 +709,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
709 newflags |= HASH_RENORMALIZE;
710
711 if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
711 - return error("%s: can only add regular files, symbolic links or git-directories", path);
712 + return error(_("%s: can only add regular files, symbolic links or git-directories"), path);
713
714 namelen = strlen(path);
715 if (S_ISDIR(st_mode)) {
@@ -763,7 +764,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
764 if (!intent_only) {
765 if (index_path(istate, &ce->oid, path, st, newflags)) {
766 discard_cache_entry(ce);
766 - return error("unable to index file %s", path);
767 + return error(_("unable to index file '%s'"), path);
768 }
769 } else
770 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,
783 discard_cache_entry(ce);
784 else if (add_index_entry(istate, ce, add_option)) {
785 discard_cache_entry(ce);
785 - return error("unable to add %s to index", path);
786 + return error(_("unable to add '%s' to index"), path);
787 }
788 if (verbose && !was_same)
789 printf("add '%s'\n", path);
@@ -793,7 +794,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
794 {
795 struct stat st;
796 if (lstat(path, &st))
796 - die_errno("unable to stat '%s'", path);
797 + die_errno(_("unable to stat '%s'"), path);
798 return add_to_index(istate, path, &st, flags);
799 }
800
@@ -818,7 +819,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
819 int len;
820
821 if (!verify_path(path, mode)) {
821 - error("Invalid path '%s'", path);
822 + error(_("invalid path '%s'"), path);
823 return NULL;
824 }
825
@@ -844,7 +845,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o
845 int len;
846
847 if (!verify_path(path, mode)) {
847 - error("Invalid path '%s'", path);
848 + error(_("invalid path '%s'"), path);
849 return NULL;
850 }
851
@@ -1297,12 +1298,12 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
1298 if (!ok_to_add)
1299 return -1;
1300 if (!verify_path(ce->name, ce->ce_mode))
1300 - return error("Invalid path '%s'", ce->name);
1301 + return error(_("invalid path '%s'"), ce->name);
1302
1303 if (!skip_df_check &&
1304 check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
1305 if (!ok_to_replace)
1305 - return error("'%s' appears as both a file and as a directory",
1306 + return error(_("'%s' appears as both a file and as a directory"),
1307 ce->name);
1308 pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
1309 pos = -pos-1;
@@ -1676,10 +1677,10 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
1677 int hdr_version;
1678
1679 if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
1679 - return error("bad signature");
1680 + return error(_("bad signature 0x%08x"), hdr->hdr_signature);
1681 hdr_version = ntohl(hdr->hdr_version);
1682 if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
1682 - return error("bad index version %d", hdr_version);
1683 + return error(_("bad index version %d"), hdr_version);
1684
1685 if (!verify_index_checksum)
1686 return 0;
@@ -1688,7 +1689,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
1689 the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
1690 the_hash_algo->final_fn(hash, &c);
1691 if (!hasheq(hash, (unsigned char *)hdr + size - the_hash_algo->rawsz))
1691 - return error("bad index file sha1 signature");
1692 + return error(_("bad index file sha1 signature"));
1693 return 0;
1694 }
1695
@@ -1718,9 +1719,9 @@ static int read_index_extension(struct index_state *istate,
1719 break;
1720 default:
1721 if (*ext < 'A' || 'Z' < *ext)
1721 - return error("index uses %.4s extension, which we do not understand",
1722 + return error(_("index uses %.4s extension, which we do not understand"),
1723 ext);
1723 - fprintf(stderr, "ignoring %.4s extension\n", ext);
1724 + fprintf_ln(stderr, _("ignoring %.4s extension"), ext);
1725 break;
1726 }
1727 return 0;
@@ -1767,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
1768 extended_flags = get_be16(&ondisk2->flags2) << 16;
1769 /* We do not yet understand any bit out of CE_EXTENDED_FLAGS */
1770 if (extended_flags & ~CE_EXTENDED_FLAGS)
1770 - die("Unknown index entry format %08x", extended_flags);
1771 + die(_("unknown index entry format 0x%08x"), extended_flags);
1772 flags |= extended_flags;
1773 name = ondisk2->name;
1774 }
@@ -1840,13 +1841,13 @@ static void check_ce_order(struct index_state *istate)
1841 int name_compare = strcmp(ce->name, next_ce->name);
1842
1843 if (0 < name_compare)
1843 - die("unordered stage entries in index");
1844 + die(_("unordered stage entries in index"));
1845 if (!name_compare) {
1846 if (!ce_stage(ce))
1846 - die("multiple stage entries for merged file '%s'",
1847 + die(_("multiple stage entries for merged file '%s'"),
1848 ce->name);
1849 if (ce_stage(ce) > ce_stage(next_ce))
1849 - die("unordered stage entries for '%s'",
1850 + die(_("unordered stage entries for '%s'"),
1851 ce->name);
1852 }
1853 }
@@ -2149,19 +2150,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
2150 if (fd < 0) {
2151 if (!must_exist && errno == ENOENT)
2152 return 0;
2152 - die_errno("%s: index file open failed", path);
2153 + die_errno(_("%s: index file open failed"), path);
2154 }
2155
2156 if (fstat(fd, &st))
2156 - die_errno("cannot stat the open index");
2157 + die_errno(_("%s: cannot stat the open index"), path);
2158
2159 mmap_size = xsize_t(st.st_size);
2160 if (mmap_size < sizeof(struct cache_header) + the_hash_algo->rawsz)
2160 - die("index file smaller than expected");
2161 + die(_("%s: index file smaller than expected"), path);
2162
2163 mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
2164 if (mmap == MAP_FAILED)
2164 - die_errno("unable to map index file");
2165 + die_errno(_("%s: unable to map index file"), path);
2166 close(fd);
2167
2168 hdr = (const struct cache_header *)mmap;
@@ -2243,7 +2244,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
2244
2245 unmap:
2246 munmap((void *)mmap, mmap_size);
2246 - die("index file corrupt");
2247 + die(_("index file corrupt"));
2248 }
2249
2250 /*
@@ -2255,7 +2256,7 @@ unmap:
2256 static void freshen_shared_index(const char *shared_index, int warn)
2257 {
2258 if (!check_and_freshen_file(shared_index, 1) && warn)
2258 - warning("could not freshen shared index '%s'", shared_index);
2259 + warning(_("could not freshen shared index '%s'"), shared_index);
2260 }
2261
2262 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,
2291 base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
2292 ret = do_read_index(split_index->base, base_path, 1);
2293 if (!oideq(&split_index->base_oid, &split_index->base->oid))
2293 - die("broken index, expect %s in %s, got %s",
2294 + die(_("broken index, expect %s in %s, got %s"),
2295 base_oid_hex, base_path,
2296 oid_to_hex(&split_index->base->oid));
2297
@@ -3076,7 +3077,7 @@ static int write_shared_index(struct index_state *istate,
3077 return ret;
3078 ret = adjust_shared_perm(get_tempfile_path(*temp));
3079 if (ret) {
3079 - error("cannot fix permission bits on %s", get_tempfile_path(*temp));
3080 + error(_("cannot fix permission bits on '%s'"), get_tempfile_path(*temp));
3081 return ret;
3082 }
3083 ret = rename_tempfile(temp,
@@ -3222,7 +3223,7 @@ int read_index_unmerged(struct index_state *istate)
3223 new_ce->ce_namelen = len;
3224 new_ce->ce_mode = ce->ce_mode;
3225 if (add_index_entry(istate, new_ce, ADD_CACHE_SKIP_DFCHECK))
3225 - return error("%s: cannot drop to stage #0",
3226 + return error(_("%s: cannot drop to stage #0"),
3227 new_ce->name);
3228 }
3229 return unmerged;
t/t1450-fsck.sh
+1 -1
@@ -754,7 +754,7 @@ test_expect_success 'detect corrupt index file in fsck' '
754 test_when_finished "mv .git/index.backup .git/index" &&
755 corrupt_index_checksum &&
756 test_must_fail git fsck --cache 2>errors &&
757 - grep "bad index file" errors
757 + test_i18ngrep "bad index file" errors
758 '
759
760 test_done