Skip to content

Commit 9d0a9e9

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 391408e commit 9d0a9e9

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

read-cache.c

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ static struct cache_entry *create_alias_ce(struct index_state *istate,
672672
struct cache_entry *new_entry;
673673

674674
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);
676677

677678
/* Ok, create the new entry using the name of the existing alias */
678679
len = ce_namelen(alias);
@@ -687,7 +688,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
687688
{
688689
struct object_id oid;
689690
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"));
691692
oidcpy(&ce->oid, &oid);
692693
}
693694

@@ -708,7 +709,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
708709
newflags |= HASH_RENORMALIZE;
709710

710711
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);
712713

713714
namelen = strlen(path);
714715
if (S_ISDIR(st_mode)) {
@@ -763,7 +764,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
763764
if (!intent_only) {
764765
if (index_path(istate, &ce->oid, path, st, newflags)) {
765766
discard_cache_entry(ce);
766-
return error("unable to index file %s", path);
767+
return error(_("unable to index file '%s'"), path);
767768
}
768769
} else
769770
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,
782783
discard_cache_entry(ce);
783784
else if (add_index_entry(istate, ce, add_option)) {
784785
discard_cache_entry(ce);
785-
return error("unable to add %s to index", path);
786+
return error(_("unable to add '%s' to index"), path);
786787
}
787788
if (verbose && !was_same)
788789
printf("add '%s'\n", path);
@@ -793,7 +794,7 @@ int add_file_to_index(struct index_state *istate, const char *path, int flags)
793794
{
794795
struct stat st;
795796
if (lstat(path, &st))
796-
die_errno("unable to stat '%s'", path);
797+
die_errno(_("unable to stat '%s'"), path);
797798
return add_to_index(istate, path, &st, flags);
798799
}
799800

@@ -818,7 +819,7 @@ struct cache_entry *make_cache_entry(struct index_state *istate,
818819
int len;
819820

820821
if (!verify_path(path, mode)) {
821-
error("Invalid path '%s'", path);
822+
error(_("invalid path '%s'"), path);
822823
return NULL;
823824
}
824825

@@ -844,7 +845,7 @@ struct cache_entry *make_transient_cache_entry(unsigned int mode, const struct o
844845
int len;
845846

846847
if (!verify_path(path, mode)) {
847-
error("Invalid path '%s'", path);
848+
error(_("invalid path '%s'"), path);
848849
return NULL;
849850
}
850851

@@ -1297,12 +1298,12 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
12971298
if (!ok_to_add)
12981299
return -1;
12991300
if (!verify_path(ce->name, ce->ce_mode))
1300-
return error("Invalid path '%s'", ce->name);
1301+
return error(_("invalid path '%s'"), ce->name);
13011302

13021303
if (!skip_df_check &&
13031304
check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
13041305
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"),
13061307
ce->name);
13071308
pos = index_name_stage_pos(istate, ce->name, ce_namelen(ce), ce_stage(ce));
13081309
pos = -pos-1;
@@ -1676,10 +1677,10 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
16761677
int hdr_version;
16771678

16781679
if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
1679-
return error("bad signature");
1680+
return error(_("bad signature 0x%08x"), hdr->hdr_signature);
16801681
hdr_version = ntohl(hdr->hdr_version);
16811682
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);
16831684

16841685
if (!verify_index_checksum)
16851686
return 0;
@@ -1688,7 +1689,7 @@ static int verify_hdr(const struct cache_header *hdr, unsigned long size)
16881689
the_hash_algo->update_fn(&c, hdr, size - the_hash_algo->rawsz);
16891690
the_hash_algo->final_fn(hash, &c);
16901691
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"));
16921693
return 0;
16931694
}
16941695

@@ -1718,9 +1719,9 @@ static int read_index_extension(struct index_state *istate,
17181719
break;
17191720
default:
17201721
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"),
17221723
ext);
1723-
fprintf(stderr, "ignoring %.4s extension\n", ext);
1724+
fprintf_ln(stderr, _("ignoring %.4s extension"), ext);
17241725
break;
17251726
}
17261727
return 0;
@@ -1767,7 +1768,7 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
17671768
extended_flags = get_be16(&ondisk2->flags2) << 16;
17681769
/* We do not yet understand any bit out of CE_EXTENDED_FLAGS */
17691770
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);
17711772
flags |= extended_flags;
17721773
name = ondisk2->name;
17731774
}
@@ -1840,13 +1841,13 @@ static void check_ce_order(struct index_state *istate)
18401841
int name_compare = strcmp(ce->name, next_ce->name);
18411842

18421843
if (0 < name_compare)
1843-
die("unordered stage entries in index");
1844+
die(_("unordered stage entries in index"));
18441845
if (!name_compare) {
18451846
if (!ce_stage(ce))
1846-
die("multiple stage entries for merged file '%s'",
1847+
die(_("multiple stage entries for merged file '%s'"),
18471848
ce->name);
18481849
if (ce_stage(ce) > ce_stage(next_ce))
1849-
die("unordered stage entries for '%s'",
1850+
die(_("unordered stage entries for '%s'"),
18501851
ce->name);
18511852
}
18521853
}
@@ -2149,19 +2150,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21492150
if (fd < 0) {
21502151
if (!must_exist && errno == ENOENT)
21512152
return 0;
2152-
die_errno("%s: index file open failed", path);
2153+
die_errno(_("%s: index file open failed"), path);
21532154
}
21542155

21552156
if (fstat(fd, &st))
2156-
die_errno("cannot stat the open index");
2157+
die_errno(_("%s: cannot stat the open index"), path);
21572158

21582159
mmap_size = xsize_t(st.st_size);
21592160
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);
21612162

21622163
mmap = xmmap(NULL, mmap_size, PROT_READ, MAP_PRIVATE, fd, 0);
21632164
if (mmap == MAP_FAILED)
2164-
die_errno("unable to map index file");
2165+
die_errno(_("%s: unable to map index file"), path);
21652166
close(fd);
21662167

21672168
hdr = (const struct cache_header *)mmap;
@@ -2243,7 +2244,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22432244

22442245
unmap:
22452246
munmap((void *)mmap, mmap_size);
2246-
die("index file corrupt");
2247+
die(_("index file corrupt"));
22472248
}
22482249

22492250
/*
@@ -2255,7 +2256,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22552256
static void freshen_shared_index(const char *shared_index, int warn)
22562257
{
22572258
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);
22592260
}
22602261

22612262
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,
22902291
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
22912292
ret = do_read_index(split_index->base, base_path, 1);
22922293
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"),
22942295
base_oid_hex, base_path,
22952296
oid_to_hex(&split_index->base->oid));
22962297

@@ -3076,7 +3077,7 @@ static int write_shared_index(struct index_state *istate,
30763077
return ret;
30773078
ret = adjust_shared_perm(get_tempfile_path(*temp));
30783079
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));
30803081
return ret;
30813082
}
30823083
ret = rename_tempfile(temp,
@@ -3222,7 +3223,7 @@ int read_index_unmerged(struct index_state *istate)
32223223
new_ce->ce_namelen = len;
32233224
new_ce->ce_mode = ce->ce_mode;
32243225
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"),
32263227
new_ce->name);
32273228
}
32283229
return unmerged;

t/t1450-fsck.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ test_expect_success 'detect corrupt index file in fsck' '
754754
test_when_finished "mv .git/index.backup .git/index" &&
755755
corrupt_index_checksum &&
756756
test_must_fail git fsck --cache 2>errors &&
757-
grep "bad index file" errors
757+
test_i18ngrep "bad index file" errors
758758
'
759759

760760
test_done

0 commit comments

Comments
 (0)