builtin/pack-objects.c: mark more strings for translation
Most of these are straight forward. GETTEXT_POISON does catch the last string in cmd_pack_objects(), but since this is --progress output, it's not supposed to be machine-readable. 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
f616db6a5cde15021dc507bf03da67f956302329
2 files changed
+53
-51
builtin/pack-objects.c
+52
-50
@@ -140,7 +140,7 @@ static void *get_delta(struct object_entry *entry)
140
141
buf = read_object_file(&entry->idx.oid, &type, &size);
142
if (!buf)
143
- die("unable to read %s", oid_to_hex(&entry->idx.oid));
143
+ die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
144
base_buf = read_object_file(&DELTA(entry)->idx.oid, &type,
145
&base_size);
146
if (!base_buf)
@@ -411,7 +411,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
411
datalen = revidx[1].offset - offset;
412
if (!pack_to_stdout && p->index_version > 1 &&
413
check_pack_crc(p, &w_curs, offset, datalen, revidx->nr)) {
414
- error("bad packed object CRC for %s",
414
+ error(_("bad packed object CRC for %s"),
415
oid_to_hex(&entry->idx.oid));
416
unuse_pack(&w_curs);
417
return write_no_reuse_object(f, entry, limit, usable_delta);
@@ -422,7 +422,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
422
423
if (!pack_to_stdout && p->index_version == 1 &&
424
check_pack_inflate(p, &w_curs, offset, datalen, entry_size)) {
425
- error("corrupt packed object for %s",
425
+ error(_("corrupt packed object for %s"),
426
oid_to_hex(&entry->idx.oid));
427
unuse_pack(&w_curs);
428
return write_no_reuse_object(f, entry, limit, usable_delta);
@@ -553,7 +553,7 @@ static enum write_one_status write_one(struct hashfile *f,
553
*/
554
recursing = (e->idx.offset == 1);
555
if (recursing) {
556
- warning("recursive delta detected for object %s",
556
+ warning(_("recursive delta detected for object %s"),
557
oid_to_hex(&e->idx.oid));
558
return WRITE_ONE_RECURSIVE;
559
} else if (e->idx.offset || e->preferred_base) {
@@ -587,7 +587,7 @@ static enum write_one_status write_one(struct hashfile *f,
587
588
/* make sure off_t is sufficiently large not to wrap */
589
if (signed_add_overflows(*offset, size))
590
- die("pack too large for current definition of off_t");
590
+ die(_("pack too large for current definition of off_t"));
591
*offset += size;
592
return WRITE_ONE_WRITTEN;
593
}
@@ -753,7 +753,8 @@ static struct object_entry **compute_write_order(void)
753
}
754
755
if (wo_end != to_pack.nr_objects)
756
- die("ordered %u objects, expected %"PRIu32, wo_end, to_pack.nr_objects);
756
+ die(_("ordered %u objects, expected %"PRIu32),
757
+ wo_end, to_pack.nr_objects);
758
759
return wo;
760
}
@@ -765,15 +766,15 @@ static off_t write_reused_pack(struct hashfile *f)
766
int fd;
767
768
if (!is_pack_valid(reuse_packfile))
768
- die("packfile is invalid: %s", reuse_packfile->pack_name);
769
+ die(_("packfile is invalid: %s"), reuse_packfile->pack_name);
770
771
fd = git_open(reuse_packfile->pack_name);
772
if (fd < 0)
772
- die_errno("unable to open packfile for reuse: %s",
773
+ die_errno(_("unable to open packfile for reuse: %s"),
774
reuse_packfile->pack_name);
775
776
if (lseek(fd, sizeof(struct pack_header), SEEK_SET) == -1)
776
- die_errno("unable to seek in reused packfile");
777
+ die_errno(_("unable to seek in reused packfile"));
778
779
if (reuse_packfile_offset < 0)
780
reuse_packfile_offset = reuse_packfile->pack_size - the_hash_algo->rawsz;
@@ -784,7 +785,7 @@ static off_t write_reused_pack(struct hashfile *f)
785
int read_pack = xread(fd, buffer, sizeof(buffer));
786
787
if (read_pack <= 0)
787
- die_errno("unable to read from reused packfile");
788
+ die_errno(_("unable to read from reused packfile"));
789
790
if (read_pack > to_write)
791
read_pack = to_write;
@@ -887,7 +888,7 @@ static void write_pack_file(void)
888
* to preserve this property.
889
*/
890
if (stat(pack_tmp_name, &st) < 0) {
890
- warning_errno("failed to stat %s", pack_tmp_name);
891
+ warning_errno(_("failed to stat %s"), pack_tmp_name);
892
} else if (!last_mtime) {
893
last_mtime = st.st_mtime;
894
} else {
@@ -895,7 +896,7 @@ static void write_pack_file(void)
896
utb.actime = st.st_atime;
897
utb.modtime = --last_mtime;
898
if (utime(pack_tmp_name, &utb) < 0)
898
- warning_errno("failed utime() on %s", pack_tmp_name);
899
+ warning_errno(_("failed utime() on %s"), pack_tmp_name);
900
}
901
902
strbuf_addf(&tmpname, "%s-", base_name);
@@ -940,8 +941,8 @@ static void write_pack_file(void)
941
free(write_order);
942
stop_progress(&progress_state);
943
if (written != nr_result)
943
- die("wrote %"PRIu32" objects while expecting %"PRIu32,
944
- written, nr_result);
944
+ die(_("wrote %"PRIu32" objects while expecting %"PRIu32),
945
+ written, nr_result);
946
}
947
948
static int no_try_delta(const char *path)
@@ -1485,7 +1486,7 @@ static void check_object(struct object_entry *entry)
1486
while (c & 128) {
1487
ofs += 1;
1488
if (!ofs || MSB(ofs, 7)) {
1488
- error("delta base offset overflow in pack for %s",
1489
+ error(_("delta base offset overflow in pack for %s"),
1490
oid_to_hex(&entry->idx.oid));
1491
goto give_up;
1492
}
@@ -1494,7 +1495,7 @@ static void check_object(struct object_entry *entry)
1495
}
1496
ofs = entry->in_pack_offset - ofs;
1497
if (ofs <= 0 || ofs >= entry->in_pack_offset) {
1497
- error("delta base offset out of bound for %s",
1498
+ error(_("delta base offset out of bound for %s"),
1499
oid_to_hex(&entry->idx.oid));
1500
goto give_up;
1501
}
@@ -1979,10 +1980,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1980
trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);
1981
read_unlock();
1982
if (!trg->data)
1982
- die("object %s cannot be read",
1983
+ die(_("object %s cannot be read"),
1984
oid_to_hex(&trg_entry->idx.oid));
1985
if (sz != trg_size)
1985
- die("object %s inconsistent object length (%lu vs %lu)",
1986
+ die(_("object %s inconsistent object length (%lu vs %lu)"),
1987
oid_to_hex(&trg_entry->idx.oid), sz,
1988
trg_size);
1989
*mem_usage += sz;
@@ -1995,7 +1996,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1996
if (src_entry->preferred_base) {
1997
static int warned = 0;
1998
if (!warned++)
1998
- warning("object %s cannot be read",
1999
+ warning(_("object %s cannot be read"),
2000
oid_to_hex(&src_entry->idx.oid));
2001
/*
2002
* Those objects are not included in the
@@ -2005,11 +2006,11 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
2006
*/
2007
return 0;
2008
}
2008
- die("object %s cannot be read",
2009
+ die(_("object %s cannot be read"),
2010
oid_to_hex(&src_entry->idx.oid));
2011
}
2012
if (sz != src_size)
2012
- die("object %s inconsistent object length (%lu vs %lu)",
2013
+ die(_("object %s inconsistent object length (%lu vs %lu)"),
2014
oid_to_hex(&src_entry->idx.oid), sz,
2015
src_size);
2016
*mem_usage += sz;
@@ -2019,7 +2020,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
2020
if (!src->index) {
2021
static int warned = 0;
2022
if (!warned++)
2022
- warning("suboptimal pack - out of memory");
2023
+ warning(_("suboptimal pack - out of memory"));
2024
return 0;
2025
}
2026
*mem_usage += sizeof_delta_index(src->index);
@@ -2346,7 +2347,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
2347
return;
2348
}
2349
if (progress > pack_to_stdout)
2349
- fprintf_ln(stderr, "Delta compression using up to %d threads",
2350
+ fprintf_ln(stderr, _("Delta compression using up to %d threads"),
2351
delta_search_threads);
2352
p = xcalloc(delta_search_threads, sizeof(*p));
2353
@@ -2387,7 +2388,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
2388
ret = pthread_create(&p[i].thread, NULL,
2389
threaded_find_deltas, &p[i]);
2390
if (ret)
2390
- die("unable to create thread: %s", strerror(ret));
2391
+ die(_("unable to create thread: %s"), strerror(ret));
2392
active_threads++;
2393
}
2394
@@ -2482,7 +2483,7 @@ static void add_tag_chain(const struct object_id *oid)
2483
tag = lookup_tag(oid);
2484
while (1) {
2485
if (!tag || parse_tag(tag) || !tag->tagged)
2485
- die("unable to pack objects reachable from tag %s",
2486
+ die(_("unable to pack objects reachable from tag %s"),
2487
oid_to_hex(oid));
2488
2489
add_object_entry(&tag->object.oid, OBJ_TAG, NULL, 0);
@@ -2548,7 +2549,7 @@ static void prepare_pack(int window, int depth)
2549
if (!entry->preferred_base) {
2550
nr_deltas++;
2551
if (oe_type(entry) < 0)
2551
- die("unable to get type of object %s",
2552
+ die(_("unable to get type of object %s"),
2553
oid_to_hex(&entry->idx.oid));
2554
} else {
2555
if (oe_type(entry) < 0) {
@@ -2572,7 +2573,7 @@ static void prepare_pack(int window, int depth)
2573
ll_find_deltas(delta_list, n, window+1, depth, &nr_done);
2574
stop_progress(&progress_state);
2575
if (nr_done != nr_deltas)
2575
- die("inconsistency with delta count");
2576
+ die(_("inconsistency with delta count"));
2577
}
2578
free(delta_list);
2579
}
@@ -2612,11 +2613,11 @@ static int git_pack_config(const char *k, const char *v, void *cb)
2613
if (!strcmp(k, "pack.threads")) {
2614
delta_search_threads = git_config_int(k, v);
2615
if (delta_search_threads < 0)
2615
- die("invalid number of threads specified (%d)",
2616
+ die(_("invalid number of threads specified (%d)"),
2617
delta_search_threads);
2618
#ifdef NO_PTHREADS
2619
if (delta_search_threads != 1) {
2619
- warning("no threads support, ignoring %s", k);
2620
+ warning(_("no threads support, ignoring %s"), k);
2621
delta_search_threads = 0;
2622
}
2623
#endif
@@ -2625,7 +2626,7 @@ static int git_pack_config(const char *k, const char *v, void *cb)
2626
if (!strcmp(k, "pack.indexversion")) {
2627
pack_idx_opts.version = git_config_int(k, v);
2628
if (pack_idx_opts.version > 2)
2628
- die("bad pack.indexversion=%"PRIu32,
2629
+ die(_("bad pack.indexversion=%"PRIu32),
2630
pack_idx_opts.version);
2631
return 0;
2632
}
@@ -2651,13 +2652,13 @@ static void read_object_list_from_stdin(void)
2652
}
2653
if (line[0] == '-') {
2654
if (get_oid_hex(line+1, &oid))
2654
- die("expected edge object ID, got garbage:\n %s",
2655
+ die(_("expected edge object ID, got garbage:\n %s"),
2656
line);
2657
add_preferred_base(&oid);
2658
continue;
2659
}
2660
if (parse_oid_hex(line, &oid, &p))
2660
- die("expected object ID, got garbage:\n %s", line);
2661
+ die(_("expected object ID, got garbage:\n %s"), line);
2662
2663
add_preferred_base_object(p + 1);
2664
add_object_entry(&oid, OBJ_NONE, p + 1, 0);
@@ -2796,7 +2797,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
2797
if (!p->pack_local || p->pack_keep || p->pack_keep_in_core)
2798
continue;
2799
if (open_pack_index(p))
2799
- die("cannot open pack index");
2800
+ die(_("cannot open pack index"));
2801
2802
ALLOC_GROW(in_pack.array,
2803
in_pack.nr + p->num_objects,
@@ -2827,7 +2828,7 @@ static int add_loose_object(const struct object_id *oid, const char *path,
2828
enum object_type type = oid_object_info(the_repository, oid, NULL);
2829
2830
if (type < 0) {
2830
- warning("loose object at %s could not be examined", path);
2831
+ warning(_("loose object at %s could not be examined"), path);
2832
return 0;
2833
}
2834
@@ -2904,7 +2905,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
2905
continue;
2906
2907
if (open_pack_index(p))
2907
- die("cannot open pack index");
2908
+ die(_("cannot open pack index"));
2909
2910
for (i = 0; i < p->num_objects; i++) {
2911
nth_packed_object_oid(&oid, p, i);
@@ -2912,7 +2913,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
2913
!has_sha1_pack_kept_or_nonlocal(&oid) &&
2914
!loosened_object_can_be_discarded(&oid, p->mtime))
2915
if (force_object_loose(&oid, p->mtime))
2915
- die("unable to force loose object");
2916
+ die(_("unable to force loose object"));
2917
}
2918
}
2919
}
@@ -2996,17 +2997,17 @@ static void get_object_list(int ac, const char **av)
2997
use_bitmap_index = 0;
2998
continue;
2999
}
2999
- die("not a rev '%s'", line);
3000
+ die(_("not a rev '%s'"), line);
3001
}
3002
if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
3002
- die("bad revision '%s'", line);
3003
+ die(_("bad revision '%s'"), line);
3004
}
3005
3006
if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
3007
return;
3008
3009
if (prepare_revision_walk(&revs))
3009
- die("revision walk setup failed");
3010
+ die(_("revision walk setup failed"));
3011
mark_edges_uninteresting(&revs, show_edge);
3012
3013
if (!fn_show_object)
@@ -3019,9 +3020,9 @@ static void get_object_list(int ac, const char **av)
3020
revs.ignore_missing_links = 1;
3021
if (add_unseen_recent_objects_to_traversal(&revs,
3022
unpack_unreachable_expiration))
3022
- die("unable to add recent objects");
3023
+ die(_("unable to add recent objects"));
3024
if (prepare_revision_walk(&revs))
3024
- die("revision walk setup failed");
3025
+ die(_("revision walk setup failed"));
3026
traverse_commit_list(&revs, record_recent_commit,
3027
record_recent_object, NULL);
3028
}
@@ -3256,35 +3257,35 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3257
if (pack_compression_level == -1)
3258
pack_compression_level = Z_DEFAULT_COMPRESSION;
3259
else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION)
3259
- die("bad pack compression level %d", pack_compression_level);
3260
+ die(_("bad pack compression level %d"), pack_compression_level);
3261
3262
if (!delta_search_threads) /* --threads=0 means autodetect */
3263
delta_search_threads = online_cpus();
3264
3265
#ifdef NO_PTHREADS
3266
if (delta_search_threads != 1)
3266
- warning("no threads support, ignoring --threads");
3267
+ warning(_("no threads support, ignoring --threads"));
3268
#endif
3269
if (!pack_to_stdout && !pack_size_limit)
3270
pack_size_limit = pack_size_limit_cfg;
3271
if (pack_to_stdout && pack_size_limit)
3271
- die("--max-pack-size cannot be used to build a pack for transfer");
3272
+ die(_("--max-pack-size cannot be used to build a pack for transfer"));
3273
if (pack_size_limit && pack_size_limit < 1024*1024) {
3273
- warning("minimum pack size limit is 1 MiB");
3274
+ warning(_("minimum pack size limit is 1 MiB"));
3275
pack_size_limit = 1024*1024;
3276
}
3277
3278
if (!pack_to_stdout && thin)
3278
- die("--thin cannot be used to build an indexable pack.");
3279
+ die(_("--thin cannot be used to build an indexable pack"));
3280
3281
if (keep_unreachable && unpack_unreachable)
3281
- die("--keep-unreachable and --unpack-unreachable are incompatible");
3282
+ die(_("--keep-unreachable and --unpack-unreachable are incompatible"));
3283
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
3284
unpack_unreachable_expiration = 0;
3285
3286
if (filter_options.choice) {
3287
if (!pack_to_stdout)
3287
- die("cannot use --filter without --stdout");
3288
+ die(_("cannot use --filter without --stdout"));
3289
use_bitmap_index = 0;
3290
}
3291
@@ -3358,8 +3359,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
3359
prepare_pack(window, depth);
3360
write_pack_file();
3361
if (progress)
3361
- fprintf_ln(stderr, "Total %"PRIu32" (delta %"PRIu32"),"
3362
- " reused %"PRIu32" (delta %"PRIu32")",
3362
+ fprintf_ln(stderr,
3363
+ _("Total %"PRIu32" (delta %"PRIu32"),"
3364
+ " reused %"PRIu32" (delta %"PRIu32")"),
3365
written, written_delta, reused, reused_delta);
3366
return 0;
3367
}
t/t5500-fetch-pack.sh
+1
-1
@@ -403,7 +403,7 @@ test_expect_success 'fetch creating new shallow root' '
403
git fetch --depth=1 --progress 2>actual &&
404
# This should fetch only the empty commit, no tree or
405
# blob objects
406
- grep "remote: Total 1" actual
406
+ test_i18ngrep "remote: Total 1" actual
407
)
408
'
409