sha1-file.c: mark more strings for translation
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
Jul 21, 2018 at 09:49 UTC
259328b7315ef9aa316b118d6be2d0b997aba81e
1 file changed
+52
-52
sha1-file.c
+52
-52
@@ -378,8 +378,8 @@ static int alt_odb_usable(struct raw_object_store *o,
378
379
/* Detect cases where alternate disappeared */
380
if (!is_directory(path->buf)) {
381
- error("object directory %s does not exist; "
382
- "check .git/objects/info/alternates",
381
+ error(_("object directory %s does not exist; "
382
+ "check .git/objects/info/alternates"),
383
path->buf);
384
return 0;
385
}
@@ -429,7 +429,7 @@ static int link_alt_odb_entry(struct repository *r, const char *entry,
429
strbuf_addstr(&pathbuf, entry);
430
431
if (strbuf_normalize_path(&pathbuf) < 0 && relative_base) {
432
- error("unable to normalize alternate object path: %s",
432
+ error(_("unable to normalize alternate object path: %s"),
433
pathbuf.buf);
434
strbuf_release(&pathbuf);
435
return -1;
@@ -500,14 +500,14 @@ static void link_alt_odb_entries(struct repository *r, const char *alt,
500
return;
501
502
if (depth > 5) {
503
- error("%s: ignoring alternate object stores, nesting too deep.",
503
+ error(_("%s: ignoring alternate object stores, nesting too deep"),
504
relative_base);
505
return;
506
}
507
508
strbuf_add_absolute_path(&objdirbuf, r->objects->objectdir);
509
if (strbuf_normalize_path(&objdirbuf) < 0)
510
- die("unable to normalize object directory: %s",
510
+ die(_("unable to normalize object directory: %s"),
511
objdirbuf.buf);
512
513
while (*alt) {
@@ -562,7 +562,7 @@ void add_to_alternates_file(const char *reference)
562
hold_lock_file_for_update(&lock, alts, LOCK_DIE_ON_ERROR);
563
out = fdopen_lock_file(&lock, "w");
564
if (!out)
565
- die_errno("unable to fdopen alternates lockfile");
565
+ die_errno(_("unable to fdopen alternates lockfile"));
566
567
in = fopen(alts, "r");
568
if (in) {
@@ -580,14 +580,14 @@ void add_to_alternates_file(const char *reference)
580
fclose(in);
581
}
582
else if (errno != ENOENT)
583
- die_errno("unable to read alternates file");
583
+ die_errno(_("unable to read alternates file"));
584
585
if (found) {
586
rollback_lock_file(&lock);
587
} else {
588
fprintf_or_die(out, "%s\n", reference);
589
if (commit_lock_file(&lock))
590
- die_errno("unable to move new alternates file into place");
590
+ die_errno(_("unable to move new alternates file into place"));
591
if (the_repository->objects->alt_odb_tail)
592
link_alt_odb_entries(the_repository, reference,
593
'\n', NULL, 0);
@@ -778,7 +778,7 @@ static void mmap_limit_check(size_t length)
778
limit = SIZE_MAX;
779
}
780
if (length > limit)
781
- die("attempting to mmap %"PRIuMAX" over limit %"PRIuMAX,
781
+ die(_("attempting to mmap %"PRIuMAX" over limit %"PRIuMAX),
782
(uintmax_t)length, (uintmax_t)limit);
783
}
784
@@ -803,7 +803,7 @@ void *xmmap(void *start, size_t length,
803
{
804
void *ret = xmmap_gently(start, length, prot, flags, fd, offset);
805
if (ret == MAP_FAILED)
806
- die_errno("mmap failed");
806
+ die_errno(_("mmap failed"));
807
return ret;
808
}
809
@@ -970,7 +970,7 @@ static void *map_sha1_file_1(struct repository *r, const char *path,
970
*size = xsize_t(st.st_size);
971
if (!*size) {
972
/* mmap() is forbidden on empty files */
973
- error("object file %s is empty", path);
973
+ error(_("object file %s is empty"), path);
974
return NULL;
975
}
976
map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -1090,9 +1090,9 @@ static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long s
1090
}
1091
1092
if (status < 0)
1093
- error("corrupt loose object '%s'", sha1_to_hex(sha1));
1093
+ error(_("corrupt loose object '%s'"), sha1_to_hex(sha1));
1094
else if (stream->avail_in)
1095
- error("garbage at end of loose object '%s'",
1095
+ error(_("garbage at end of loose object '%s'"),
1096
sha1_to_hex(sha1));
1097
free(buf);
1098
return NULL;
@@ -1134,7 +1134,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,
1134
if ((flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE) && (type < 0))
1135
type = 0;
1136
else if (type < 0)
1137
- die("invalid object type");
1137
+ die(_("invalid object type"));
1138
if (oi->typep)
1139
*oi->typep = type;
1140
@@ -1216,19 +1216,19 @@ static int sha1_loose_object_info(struct repository *r,
1216
*oi->disk_sizep = mapsize;
1217
if ((flags & OBJECT_INFO_ALLOW_UNKNOWN_TYPE)) {
1218
if (unpack_sha1_header_to_strbuf(&stream, map, mapsize, hdr, sizeof(hdr), &hdrbuf) < 0)
1219
- status = error("unable to unpack %s header with --allow-unknown-type",
1219
+ status = error(_("unable to unpack %s header with --allow-unknown-type"),
1220
sha1_to_hex(sha1));
1221
} else if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0)
1222
- status = error("unable to unpack %s header",
1222
+ status = error(_("unable to unpack %s header"),
1223
sha1_to_hex(sha1));
1224
if (status < 0)
1225
; /* Do nothing */
1226
else if (hdrbuf.len) {
1227
if ((status = parse_sha1_header_extended(hdrbuf.buf, oi, flags)) < 0)
1228
- status = error("unable to parse %s header with --allow-unknown-type",
1228
+ status = error(_("unable to parse %s header with --allow-unknown-type"),
1229
sha1_to_hex(sha1));
1230
} else if ((status = parse_sha1_header_extended(hdr, oi, flags)) < 0)
1231
- status = error("unable to parse %s header", sha1_to_hex(sha1));
1231
+ status = error(_("unable to parse %s header"), sha1_to_hex(sha1));
1232
1233
if (status >= 0 && oi->contentp) {
1234
*oi->contentp = unpack_sha1_rest(&stream, hdr,
@@ -1419,19 +1419,19 @@ void *read_object_file_extended(const struct object_id *oid,
1419
return data;
1420
1421
if (errno && errno != ENOENT)
1422
- die_errno("failed to read object %s", oid_to_hex(oid));
1422
+ die_errno(_("failed to read object %s"), oid_to_hex(oid));
1423
1424
/* die if we replaced an object with one that does not exist */
1425
if (repl != oid)
1426
- die("replacement %s not found for %s",
1426
+ die(_("replacement %s not found for %s"),
1427
oid_to_hex(repl), oid_to_hex(oid));
1428
1429
if (!stat_sha1_file(the_repository, repl->hash, &st, &path))
1430
- die("loose object %s (stored in %s) is corrupt",
1430
+ die(_("loose object %s (stored in %s) is corrupt"),
1431
oid_to_hex(repl), path);
1432
1433
if ((p = has_packed_and_bad(repl->hash)) != NULL)
1434
- die("packed object %s (stored in %s) is corrupt",
1434
+ die(_("packed object %s (stored in %s) is corrupt"),
1435
oid_to_hex(repl), p->pack_name);
1436
1437
return NULL;
@@ -1533,21 +1533,21 @@ int finalize_object_file(const char *tmpfile, const char *filename)
1533
unlink_or_warn(tmpfile);
1534
if (ret) {
1535
if (ret != EEXIST) {
1536
- return error_errno("unable to write sha1 filename %s", filename);
1536
+ return error_errno(_("unable to write sha1 filename %s"), filename);
1537
}
1538
/* FIXME!!! Collision check here ? */
1539
}
1540
1541
out:
1542
if (adjust_shared_perm(filename))
1543
- return error("unable to set permission to '%s'", filename);
1543
+ return error(_("unable to set permission to '%s'"), filename);
1544
return 0;
1545
}
1546
1547
static int write_buffer(int fd, const void *buf, size_t len)
1548
{
1549
if (write_in_full(fd, buf, len) < 0)
1550
- return error_errno("file write error");
1550
+ return error_errno(_("file write error"));
1551
return 0;
1552
}
1553
@@ -1566,7 +1566,7 @@ static void close_sha1_file(int fd)
1566
if (fsync_object_files)
1567
fsync_or_die(fd, "sha1 file");
1568
if (close(fd) != 0)
1569
- die_errno("error when closing sha1 file");
1569
+ die_errno(_("error when closing sha1 file"));
1570
}
1571
1572
/* Size of directory component, including the ending '/' */
@@ -1632,9 +1632,9 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
1632
fd = create_tmpfile(&tmp_file, filename.buf);
1633
if (fd < 0) {
1634
if (errno == EACCES)
1635
- return error("insufficient permission for adding an object to repository database %s", get_object_directory());
1635
+ return error(_("insufficient permission for adding an object to repository database %s"), get_object_directory());
1636
else
1637
- return error_errno("unable to create temporary file");
1637
+ return error_errno(_("unable to create temporary file"));
1638
}
1639
1640
/* Set it up */
@@ -1658,21 +1658,21 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
1658
ret = git_deflate(&stream, Z_FINISH);
1659
the_hash_algo->update_fn(&c, in0, stream.next_in - in0);
1660
if (write_buffer(fd, compressed, stream.next_out - compressed) < 0)
1661
- die("unable to write sha1 file");
1661
+ die(_("unable to write sha1 file"));
1662
stream.next_out = compressed;
1663
stream.avail_out = sizeof(compressed);
1664
} while (ret == Z_OK);
1665
1666
if (ret != Z_STREAM_END)
1667
- die("unable to deflate new object %s (%d)", oid_to_hex(oid),
1667
+ die(_("unable to deflate new object %s (%d)"), oid_to_hex(oid),
1668
ret);
1669
ret = git_deflate_end_gently(&stream);
1670
if (ret != Z_OK)
1671
- die("deflateEnd on object %s failed (%d)", oid_to_hex(oid),
1671
+ die(_("deflateEnd on object %s failed (%d)"), oid_to_hex(oid),
1672
ret);
1673
the_hash_algo->final_fn(parano_oid.hash, &c);
1674
if (oidcmp(oid, ¶no_oid) != 0)
1675
- die("confused by unstable object source data for %s",
1675
+ die(_("confused by unstable object source data for %s"),
1676
oid_to_hex(oid));
1677
1678
close_sha1_file(fd);
@@ -1682,7 +1682,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
1682
utb.actime = mtime;
1683
utb.modtime = mtime;
1684
if (utime(tmp_file.buf, &utb) < 0)
1685
- warning_errno("failed utime() on %s", tmp_file.buf);
1685
+ warning_errno(_("failed utime() on %s"), tmp_file.buf);
1686
}
1687
1688
return finalize_object_file(tmp_file.buf, filename.buf);
@@ -1757,7 +1757,7 @@ int force_object_loose(const struct object_id *oid, time_t mtime)
1757
return 0;
1758
buf = read_object(oid->hash, &type, &len);
1759
if (!buf)
1760
- return error("cannot read sha1_file for %s", oid_to_hex(oid));
1760
+ return error(_("cannot read sha1_file for %s"), oid_to_hex(oid));
1761
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
1762
ret = write_loose_object(oid, hdr, hdrlen, buf, len, mtime);
1763
free(buf);
@@ -1802,7 +1802,7 @@ static void check_commit(const void *buf, size_t size)
1802
struct commit c;
1803
memset(&c, 0, sizeof(c));
1804
if (parse_commit_buffer(&c, buf, size, 0))
1805
- die("corrupt commit");
1805
+ die(_("corrupt commit"));
1806
}
1807
1808
static void check_tag(const void *buf, size_t size)
@@ -1810,7 +1810,7 @@ static void check_tag(const void *buf, size_t size)
1810
struct tag t;
1811
memset(&t, 0, sizeof(t));
1812
if (parse_tag_buffer(&t, buf, size))
1813
- die("corrupt tag");
1813
+ die(_("corrupt tag"));
1814
}
1815
1816
static int index_mem(struct object_id *oid, void *buf, size_t size,
@@ -1903,10 +1903,10 @@ static int index_core(struct object_id *oid, int fd, size_t size,
1903
char *buf = xmalloc(size);
1904
ssize_t read_result = read_in_full(fd, buf, size);
1905
if (read_result < 0)
1906
- ret = error_errno("read error while indexing %s",
1906
+ ret = error_errno(_("read error while indexing %s"),
1907
path ? path : "<unknown>");
1908
else if (read_result != size)
1909
- ret = error("short read while indexing %s",
1909
+ ret = error(_("short read while indexing %s"),
1910
path ? path : "<unknown>");
1911
else
1912
ret = index_mem(oid, buf, size, type, path, flags);
@@ -1977,7 +1977,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
1977
if (fd < 0)
1978
return error_errno("open(\"%s\")", path);
1979
if (index_fd(oid, fd, st, OBJ_BLOB, path, flags) < 0)
1980
- return error("%s: failed to insert into database",
1980
+ return error(_("%s: failed to insert into database"),
1981
path);
1982
break;
1983
case S_IFLNK:
@@ -1986,13 +1986,13 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
1986
if (!(flags & HASH_WRITE_OBJECT))
1987
hash_object_file(sb.buf, sb.len, blob_type, oid);
1988
else if (write_object_file(sb.buf, sb.len, blob_type, oid))
1989
- rc = error("%s: failed to insert into database", path);
1989
+ rc = error(_("%s: failed to insert into database"), path);
1990
strbuf_release(&sb);
1991
break;
1992
case S_IFDIR:
1993
return resolve_gitlink_ref(path, "HEAD", oid);
1994
default:
1995
- return error("%s: unsupported file type", path);
1995
+ return error(_("%s: unsupported file type"), path);
1996
}
1997
return rc;
1998
}
@@ -2016,9 +2016,9 @@ void assert_oid_type(const struct object_id *oid, enum object_type expect)
2016
{
2017
enum object_type type = oid_object_info(the_repository, oid, NULL);
2018
if (type < 0)
2019
- die("%s is not a valid object", oid_to_hex(oid));
2019
+ die(_("%s is not a valid object"), oid_to_hex(oid));
2020
if (type != expect)
2021
- die("%s is not a valid '%s' object", oid_to_hex(oid),
2021
+ die(_("%s is not a valid '%s' object"), oid_to_hex(oid),
2022
type_name(expect));
2023
}
2024
@@ -2045,7 +2045,7 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
2045
dir = opendir(path->buf);
2046
if (!dir) {
2047
if (errno != ENOENT)
2048
- r = error_errno("unable to open %s", path->buf);
2048
+ r = error_errno(_("unable to open %s"), path->buf);
2049
strbuf_setlen(path, origlen);
2050
return r;
2051
}
@@ -2202,18 +2202,18 @@ static int check_stream_sha1(git_zstream *stream,
2202
git_inflate_end(stream);
2203
2204
if (status != Z_STREAM_END) {
2205
- error("corrupt loose object '%s'", sha1_to_hex(expected_sha1));
2205
+ error(_("corrupt loose object '%s'"), sha1_to_hex(expected_sha1));
2206
return -1;
2207
}
2208
if (stream->avail_in) {
2209
- error("garbage at end of loose object '%s'",
2209
+ error(_("garbage at end of loose object '%s'"),
2210
sha1_to_hex(expected_sha1));
2211
return -1;
2212
}
2213
2214
the_hash_algo->final_fn(real_sha1, &c);
2215
if (hashcmp(expected_sha1, real_sha1)) {
2216
- error("sha1 mismatch for %s (expected %s)", path,
2216
+ error(_("sha1 mismatch for %s (expected %s)"), path,
2217
sha1_to_hex(expected_sha1));
2218
return -1;
2219
}
@@ -2237,18 +2237,18 @@ int read_loose_object(const char *path,
2237
2238
map = map_sha1_file_1(the_repository, path, NULL, &mapsize);
2239
if (!map) {
2240
- error_errno("unable to mmap %s", path);
2240
+ error_errno(_("unable to mmap %s"), path);
2241
goto out;
2242
}
2243
2244
if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0) {
2245
- error("unable to unpack header of %s", path);
2245
+ error(_("unable to unpack header of %s"), path);
2246
goto out;
2247
}
2248
2249
*type = parse_sha1_header(hdr, size);
2250
if (*type < 0) {
2251
- error("unable to parse header of %s", path);
2251
+ error(_("unable to parse header of %s"), path);
2252
git_inflate_end(&stream);
2253
goto out;
2254
}
@@ -2259,13 +2259,13 @@ int read_loose_object(const char *path,
2259
} else {
2260
*contents = unpack_sha1_rest(&stream, hdr, *size, expected_oid->hash);
2261
if (!*contents) {
2262
- error("unable to unpack contents of %s", path);
2262
+ error(_("unable to unpack contents of %s"), path);
2263
git_inflate_end(&stream);
2264
goto out;
2265
}
2266
if (check_object_signature(expected_oid, *contents,
2267
*size, type_name(*type))) {
2268
- error("sha1 mismatch for %s (expected %s)", path,
2268
+ error(_("sha1 mismatch for %s (expected %s)"), path,
2269
oid_to_hex(expected_oid));
2270
free(*contents);
2271
goto out;