i18n: index-pack: mark 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
Apr 23, 2012 at 19:30 UTC
c2b97ecf5109c238fae9051615e413897f347584
1 file changed
+68
-57
builtin/index-pack.c
+68
-57
@@ -81,7 +81,7 @@ static int mark_link(struct object *obj, int type, void *data)
81
return -1;
82
83
if (type != OBJ_ANY && obj->type != type)
84
- die("object type mismatch at %s", sha1_to_hex(obj->sha1));
84
+ die(_("object type mismatch at %s"), sha1_to_hex(obj->sha1));
85
86
obj->flags |= FLAG_LINK;
87
return 0;
@@ -101,7 +101,7 @@ static void check_object(struct object *obj)
101
unsigned long size;
102
int type = sha1_object_info(obj->sha1, &size);
103
if (type != obj->type || type <= 0)
104
- die("object of unexpected type");
104
+ die(_("object of unexpected type"));
105
obj->flags |= FLAG_CHECKED;
106
return;
107
}
@@ -138,15 +138,18 @@ static void *fill(int min)
138
if (min <= input_len)
139
return input_buffer + input_offset;
140
if (min > sizeof(input_buffer))
141
- die("cannot fill %d bytes", min);
141
+ die(Q_("cannot fill %d byte",
142
+ "cannot fill %d bytes",
143
+ min),
144
+ min);
145
flush();
146
do {
147
ssize_t ret = xread(input_fd, input_buffer + input_len,
148
sizeof(input_buffer) - input_len);
149
if (ret <= 0) {
150
if (!ret)
148
- die("early EOF");
149
- die_errno("read error on input");
151
+ die(_("early EOF"));
152
+ die_errno(_("read error on input"));
153
}
154
input_len += ret;
155
if (from_stdin)
@@ -158,14 +161,14 @@ static void *fill(int min)
161
static void use(int bytes)
162
{
163
if (bytes > input_len)
161
- die("used more bytes than were available");
164
+ die(_("used more bytes than were available"));
165
input_crc32 = crc32(input_crc32, input_buffer + input_offset, bytes);
166
input_len -= bytes;
167
input_offset += bytes;
168
169
/* make sure off_t is sufficiently large not to wrap */
170
if (signed_add_overflows(consumed_bytes, bytes))
168
- die("pack too large for current definition of off_t");
171
+ die(_("pack too large for current definition of off_t"));
172
consumed_bytes += bytes;
173
}
174
@@ -181,12 +184,12 @@ static const char *open_pack_file(const char *pack_name)
184
} else
185
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
186
if (output_fd < 0)
184
- die_errno("unable to create '%s'", pack_name);
187
+ die_errno(_("unable to create '%s'"), pack_name);
188
pack_fd = output_fd;
189
} else {
190
input_fd = open(pack_name, O_RDONLY);
191
if (input_fd < 0)
189
- die_errno("cannot open packfile '%s'", pack_name);
192
+ die_errno(_("cannot open packfile '%s'"), pack_name);
193
output_fd = -1;
194
pack_fd = input_fd;
195
}
@@ -200,7 +203,7 @@ static void parse_pack_header(void)
203
204
/* Header consistency check */
205
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
203
- die("pack signature mismatch");
206
+ die(_("pack signature mismatch"));
207
if (!pack_version_ok(hdr->hdr_version))
208
die("pack version %"PRIu32" unsupported",
209
ntohl(hdr->hdr_version));
@@ -220,7 +223,7 @@ static NORETURN void bad_object(unsigned long offset, const char *format, ...)
223
va_start(params, format);
224
vsnprintf(buf, sizeof(buf), format, params);
225
va_end(params);
223
- die("pack has bad object at offset %lu: %s", offset, buf);
226
+ die(_("pack has bad object at offset %lu: %s"), offset, buf);
227
}
228
229
static struct base_data *alloc_base_data(void)
@@ -294,7 +297,7 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)
297
use(input_len - stream.avail_in);
298
} while (status == Z_OK);
299
if (stream.total_out != size || status != Z_STREAM_END)
297
- bad_object(offset, "inflate returned %d", status);
300
+ bad_object(offset, _("inflate returned %d"), status);
301
git_inflate_end(&stream);
302
return buf;
303
}
@@ -339,7 +342,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
342
while (c & 128) {
343
base_offset += 1;
344
if (!base_offset || MSB(base_offset, 7))
342
- bad_object(obj->idx.offset, "offset value overflow for delta base object");
345
+ bad_object(obj->idx.offset, _("offset value overflow for delta base object"));
346
p = fill(1);
347
c = *p;
348
use(1);
@@ -347,7 +350,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
350
}
351
delta_base->offset = obj->idx.offset - base_offset;
352
if (delta_base->offset <= 0 || delta_base->offset >= obj->idx.offset)
350
- bad_object(obj->idx.offset, "delta base offset is out of bound");
353
+ bad_object(obj->idx.offset, _("delta base offset is out of bound"));
354
break;
355
case OBJ_COMMIT:
356
case OBJ_TREE:
@@ -355,7 +358,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
358
case OBJ_TAG:
359
break;
360
default:
358
- bad_object(obj->idx.offset, "unknown object type %d", obj->type);
361
+ bad_object(obj->idx.offset, _("unknown object type %d"), obj->type);
362
}
363
obj->hdr_size = consumed_bytes - obj->idx.offset;
364
@@ -384,9 +387,12 @@ static void *get_data_from_pack(struct object_entry *obj)
387
ssize_t n = (len < 64*1024) ? len : 64*1024;
388
n = pread(pack_fd, inbuf, n, from);
389
if (n < 0)
387
- die_errno("cannot pread pack file");
390
+ die_errno(_("cannot pread pack file"));
391
if (!n)
389
- die("premature end of pack file, %lu bytes missing", len);
392
+ die(Q_("premature end of pack file, %lu byte missing",
393
+ "premature end of pack file, %lu bytes missing",
394
+ len),
395
+ len);
396
from += n;
397
len -= n;
398
stream.next_in = inbuf;
@@ -396,7 +402,7 @@ static void *get_data_from_pack(struct object_entry *obj)
402
403
/* This has been inflated OK when first encountered, so... */
404
if (status != Z_STREAM_END || stream.total_out != obj->size)
399
- die("serious inflate inconsistency");
405
+ die(_("serious inflate inconsistency"));
406
407
git_inflate_end(&stream);
408
free(inbuf);
@@ -467,10 +473,10 @@ static void sha1_object(const void *data, unsigned long size,
473
unsigned long has_size;
474
has_data = read_sha1_file(sha1, &has_type, &has_size);
475
if (!has_data)
470
- die("cannot read existing object %s", sha1_to_hex(sha1));
476
+ die(_("cannot read existing object %s"), sha1_to_hex(sha1));
477
if (size != has_size || type != has_type ||
478
memcmp(data, has_data, size) != 0)
473
- die("SHA1 COLLISION FOUND WITH %s !", sha1_to_hex(sha1));
479
+ die(_("SHA1 COLLISION FOUND WITH %s !"), sha1_to_hex(sha1));
480
free(has_data);
481
}
482
if (strict) {
@@ -479,7 +485,7 @@ static void sha1_object(const void *data, unsigned long size,
485
if (blob)
486
blob->object.flags |= FLAG_CHECKED;
487
else
482
- die("invalid blob object %s", sha1_to_hex(sha1));
488
+ die(_("invalid blob object %s"), sha1_to_hex(sha1));
489
} else {
490
struct object *obj;
491
int eaten;
@@ -491,11 +497,11 @@ static void sha1_object(const void *data, unsigned long size,
497
*/
498
obj = parse_object_buffer(sha1, type, size, buf, &eaten);
499
if (!obj)
494
- die("invalid %s", typename(type));
500
+ die(_("invalid %s"), typename(type));
501
if (fsck_object(obj, 1, fsck_error_function))
496
- die("Error in object");
502
+ die(_("Error in object"));
503
if (fsck_walk(obj, mark_link, NULL))
498
- die("Not all child objects of %s are reachable", sha1_to_hex(obj->sha1));
504
+ die(_("Not all child objects of %s are reachable"), sha1_to_hex(obj->sha1));
505
506
if (obj->type == OBJ_TREE) {
507
struct tree *item = (struct tree *) obj;
@@ -567,7 +573,7 @@ static void *get_base_data(struct base_data *c)
573
&c->size);
574
free(raw);
575
if (!c->data)
570
- bad_object(obj->idx.offset, "failed to apply delta");
576
+ bad_object(obj->idx.offset, _("failed to apply delta"));
577
base_cache_used += c->size;
578
prune_base_data(c);
579
}
@@ -593,7 +599,7 @@ static void resolve_delta(struct object_entry *delta_obj,
599
delta_data, delta_obj->size, &result->size);
600
free(delta_data);
601
if (!result->data)
596
- bad_object(delta_obj->idx.offset, "failed to apply delta");
602
+ bad_object(delta_obj->idx.offset, _("failed to apply delta"));
603
sha1_object(result->data, result->size, delta_obj->real_type,
604
delta_obj->idx.sha1);
605
nr_resolved_deltas++;
@@ -697,7 +703,7 @@ static void parse_pack_objects(unsigned char *sha1)
703
*/
704
if (verbose)
705
progress = start_progress(
700
- from_stdin ? "Receiving objects" : "Indexing objects",
706
+ from_stdin ? _("Receiving objects") : _("Indexing objects"),
707
nr_objects);
708
for (i = 0; i < nr_objects; i++) {
709
struct object_entry *obj = &objects[i];
@@ -719,15 +725,15 @@ static void parse_pack_objects(unsigned char *sha1)
725
flush();
726
git_SHA1_Final(sha1, &input_ctx);
727
if (hashcmp(fill(20), sha1))
722
- die("pack is corrupted (SHA1 mismatch)");
728
+ die(_("pack is corrupted (SHA1 mismatch)"));
729
use(20);
730
731
/* If input_fd is a file, we should have reached its end now. */
732
if (fstat(input_fd, &st))
727
- die_errno("cannot fstat packfile");
733
+ die_errno(_("cannot fstat packfile"));
734
if (S_ISREG(st.st_mode) &&
735
lseek(input_fd, 0, SEEK_CUR) - input_len != st.st_size)
730
- die("pack has junk at the end");
736
+ die(_("pack has junk at the end"));
737
738
if (!nr_deltas)
739
return;
@@ -745,7 +751,7 @@ static void parse_pack_objects(unsigned char *sha1)
751
* for some more deltas.
752
*/
753
if (verbose)
748
- progress = start_progress("Resolving deltas", nr_deltas);
754
+ progress = start_progress(_("Resolving deltas"), nr_deltas);
755
for (i = 0; i < nr_objects; i++) {
756
struct object_entry *obj = &objects[i];
757
struct base_data *base_obj = alloc_base_data();
@@ -778,7 +784,7 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)
784
} while (status == Z_OK);
785
786
if (status != Z_STREAM_END)
781
- die("unable to deflate appended object (%d)", status);
787
+ die(_("unable to deflate appended object (%d)"), status);
788
size = stream.total_out;
789
git_deflate_end(&stream);
790
return size;
@@ -857,7 +863,7 @@ static void fix_unresolved_deltas(struct sha1file *f, int nr_unresolved)
863
864
if (check_sha1_signature(d->base.sha1, base_obj->data,
865
base_obj->size, typename(type)))
860
- die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
866
+ die(_("local object %s is corrupt"), sha1_to_hex(d->base.sha1));
867
base_obj->obj = append_obj_to_pack(f, d->base.sha1,
868
base_obj->data, base_obj->size, type);
869
find_unresolved_deltas(base_obj);
@@ -881,7 +887,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
887
fsync_or_die(output_fd, curr_pack_name);
888
err = close(output_fd);
889
if (err)
884
- die_errno("error while closing pack file");
890
+ die_errno(_("error while closing pack file"));
891
}
892
893
if (keep_msg) {
@@ -894,7 +900,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
900
901
if (keep_fd < 0) {
902
if (errno != EEXIST)
897
- die_errno("cannot write keep file '%s'",
903
+ die_errno(_("cannot write keep file '%s'"),
904
keep_name);
905
} else {
906
if (keep_msg_len > 0) {
@@ -902,7 +908,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
908
write_or_die(keep_fd, "\n", 1);
909
}
910
if (close(keep_fd) != 0)
905
- die_errno("cannot close written keep file '%s'",
911
+ die_errno(_("cannot close written keep file '%s'"),
912
keep_name);
913
report = "keep";
914
}
@@ -915,7 +921,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
921
final_pack_name = name;
922
}
923
if (move_temp_to_file(curr_pack_name, final_pack_name))
918
- die("cannot store pack file");
924
+ die(_("cannot store pack file"));
925
} else if (from_stdin)
926
chmod(final_pack_name, 0444);
927
@@ -926,7 +932,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
932
final_index_name = name;
933
}
934
if (move_temp_to_file(curr_index_name, final_index_name))
929
- die("cannot store index file");
935
+ die(_("cannot store index file"));
936
} else
937
chmod(final_index_name, 0444);
938
@@ -1015,9 +1021,9 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
1021
struct packed_git *p = add_packed_git(pack_name, strlen(pack_name), 1);
1022
1023
if (!p)
1018
- die("Cannot open existing pack file '%s'", pack_name);
1024
+ die(_("Cannot open existing pack file '%s'"), pack_name);
1025
if (open_pack_index(p))
1020
- die("Cannot open existing pack idx file for '%s'", pack_name);
1026
+ die(_("Cannot open existing pack idx file for '%s'"), pack_name);
1027
1028
/* Read the attributes from the existing idx file */
1029
opts->version = p->index_version;
@@ -1064,15 +1070,18 @@ static void show_pack_info(int stat_only)
1070
}
1071
1072
if (baseobjects)
1067
- printf("non delta: %d object%s\n",
1068
- baseobjects, baseobjects > 1 ? "s" : "");
1073
+ printf_ln(Q_("non delta: %d object",
1074
+ "non delta: %d objects",
1075
+ baseobjects),
1076
+ baseobjects);
1077
for (i = 0; i < deepest_delta; i++) {
1078
if (!chain_histogram[i])
1079
continue;
1072
- printf("chain length = %d: %lu object%s\n",
1073
- i + 1,
1074
- chain_histogram[i],
1075
- chain_histogram[i] > 1 ? "s" : "");
1080
+ printf_ln(Q_("chain length = %d: %lu object",
1081
+ "chain length = %d: %lu objects",
1082
+ chain_histogram[i]),
1083
+ i + 1,
1084
+ chain_histogram[i]);
1085
}
1086
}
1087
@@ -1095,7 +1104,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1104
reset_pack_idx_option(&opts);
1105
git_config(git_index_pack_config, &opts);
1106
if (prefix && chdir(prefix))
1098
- die("Cannot come back to cwd");
1107
+ die(_("Cannot come back to cwd"));
1108
1109
for (i = 1; i < argc; i++) {
1110
const char *arg = argv[i];
@@ -1128,10 +1137,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1137
hdr->hdr_signature = htonl(PACK_SIGNATURE);
1138
hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));
1139
if (*c != ',')
1131
- die("bad %s", arg);
1140
+ die(_("bad %s"), arg);
1141
hdr->hdr_entries = htonl(strtoul(c + 1, &c, 10));
1142
if (*c)
1134
- die("bad %s", arg);
1143
+ die(_("bad %s"), arg);
1144
input_len = sizeof(*hdr);
1145
} else if (!strcmp(arg, "-v")) {
1146
verbose = 1;
@@ -1143,11 +1152,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1152
char *c;
1153
opts.version = strtoul(arg + 16, &c, 10);
1154
if (opts.version > 2)
1146
- die("bad %s", arg);
1155
+ die(_("bad %s"), arg);
1156
if (*c == ',')
1157
opts.off32_limit = strtoul(c+1, &c, 0);
1158
if (*c || opts.off32_limit & 0x80000000)
1150
- die("bad %s", arg);
1159
+ die(_("bad %s"), arg);
1160
} else
1161
usage(index_pack_usage);
1162
continue;
@@ -1161,11 +1170,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1170
if (!pack_name && !from_stdin)
1171
usage(index_pack_usage);
1172
if (fix_thin_pack && !from_stdin)
1164
- die("--fix-thin cannot be used without --stdin");
1173
+ die(_("--fix-thin cannot be used without --stdin"));
1174
if (!index_name && pack_name) {
1175
int len = strlen(pack_name);
1176
if (!has_extension(pack_name, ".pack"))
1168
- die("packfile name '%s' does not end with '.pack'",
1177
+ die(_("packfile name '%s' does not end with '.pack'"),
1178
pack_name);
1179
index_name_buf = xmalloc(len);
1180
memcpy(index_name_buf, pack_name, len - 5);
@@ -1175,7 +1184,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1184
if (keep_msg && !keep_name && pack_name) {
1185
int len = strlen(pack_name);
1186
if (!has_extension(pack_name, ".pack"))
1178
- die("packfile name '%s' does not end with '.pack'",
1187
+ die(_("packfile name '%s' does not end with '.pack'"),
1188
pack_name);
1189
keep_name_buf = xmalloc(len);
1190
memcpy(keep_name_buf, pack_name, len - 5);
@@ -1184,7 +1193,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1193
}
1194
if (verify) {
1195
if (!index_name)
1187
- die("--verify with no packfile name given");
1196
+ die(_("--verify with no packfile name given"));
1197
read_idx_option(&opts, index_name);
1198
opts.flags |= WRITE_IDX_VERIFY | WRITE_IDX_STRICT;
1199
}
@@ -1208,7 +1217,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1217
int nr_unresolved = nr_deltas - nr_resolved_deltas;
1218
int nr_objects_initial = nr_objects;
1219
if (nr_unresolved <= 0)
1211
- die("confusion beyond insanity");
1220
+ die(_("confusion beyond insanity"));
1221
objects = xrealloc(objects,
1222
(nr_objects + nr_unresolved + 1)
1223
* sizeof(*objects));
@@ -1227,7 +1236,9 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1236
"(disk corruption?)", curr_pack);
1237
}
1238
if (nr_deltas != nr_resolved_deltas)
1230
- die("pack has %d unresolved deltas",
1239
+ die(Q_("pack has %d unresolved delta",
1240
+ "pack has %d unresolved deltas",
1241
+ nr_deltas - nr_resolved_deltas),
1242
nr_deltas - nr_resolved_deltas);
1243
}
1244
free(deltas);