@@ -85,7 +85,7 @@ static const char *printable_type(struct object *obj)
85
85
86
86
ret = type_name (obj -> type );
87
87
if (!ret )
88
- ret = "unknown" ;
88
+ ret = _ ( "unknown" ) ;
89
89
90
90
return ret ;
91
91
}
@@ -116,7 +116,8 @@ static int fsck_config(const char *var, const char *value, void *cb)
116
116
static int objerror (struct object * obj , const char * err )
117
117
{
118
118
errors_found |= ERROR_OBJECT ;
119
- fprintf_ln (stderr , "error in %s %s: %s" ,
119
+ /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
120
+ fprintf_ln (stderr , _ ("error in %s %s: %s" ),
120
121
printable_type (obj ), describe_object (obj ), err );
121
122
return -1 ;
122
123
}
@@ -126,11 +127,13 @@ static int fsck_error_func(struct fsck_options *o,
126
127
{
127
128
switch (type ) {
128
129
case FSCK_WARN :
129
- fprintf_ln (stderr , "warning in %s %s: %s" ,
130
+ /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
131
+ fprintf_ln (stderr , _ ("warning in %s %s: %s" ),
130
132
printable_type (obj ), describe_object (obj ), message );
131
133
return 0 ;
132
134
case FSCK_ERROR :
133
- fprintf_ln (stderr , "error in %s %s: %s" ,
135
+ /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
136
+ fprintf_ln (stderr , _ ("error in %s %s: %s" ),
134
137
printable_type (obj ), describe_object (obj ), message );
135
138
return 1 ;
136
139
default :
@@ -151,17 +154,18 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
151
154
*/
152
155
if (!obj ) {
153
156
/* ... these references to parent->fld are safe here */
154
- printf ("broken link from %7s %s\n" ,
155
- printable_type (parent ), describe_object (parent ));
156
- printf ("broken link from %7s %s\n" ,
157
- (type == OBJ_ANY ? "unknown" : type_name (type )), "unknown" );
157
+ printf_ln (_ ("broken link from %7s %s" ),
158
+ printable_type (parent ), describe_object (parent ));
159
+ printf_ln (_ ("broken link from %7s %s" ),
160
+ (type == OBJ_ANY ? _ ("unknown" ) : type_name (type )),
161
+ _ ("unknown" ));
158
162
errors_found |= ERROR_REACHABLE ;
159
163
return 1 ;
160
164
}
161
165
162
166
if (type != OBJ_ANY && obj -> type != type )
163
167
/* ... and the reference to parent is safe here */
164
- objerror (parent , "wrong object type in link" );
168
+ objerror (parent , _ ( "wrong object type in link" ) );
165
169
166
170
if (obj -> flags & REACHABLE )
167
171
return 0 ;
@@ -177,8 +181,8 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
177
181
178
182
if (!(obj -> flags & HAS_OBJ )) {
179
183
if (parent && !has_object_file (& obj -> oid )) {
180
- printf_ln ("broken link from %7s %s\n"
181
- " to %7s %s" ,
184
+ printf_ln (_ ( "broken link from %7s %s\n"
185
+ " to %7s %s" ) ,
182
186
printable_type (parent ),
183
187
describe_object (parent ),
184
188
printable_type (obj ),
@@ -246,8 +250,8 @@ static void check_reachable_object(struct object *obj)
246
250
return ;
247
251
if (has_object_pack (& obj -> oid ))
248
252
return ; /* it is in pack - forget about it */
249
- printf ( "missing %s %s\n" , printable_type (obj ),
250
- describe_object (obj ));
253
+ printf_ln ( _ ( "missing %s %s" ) , printable_type (obj ),
254
+ describe_object (obj ));
251
255
errors_found |= ERROR_REACHABLE ;
252
256
return ;
253
257
}
@@ -272,8 +276,8 @@ static void check_unreachable_object(struct object *obj)
272
276
* since this is something that is prunable.
273
277
*/
274
278
if (show_unreachable ) {
275
- printf ( "unreachable %s %s\n" , printable_type (obj ),
276
- describe_object (obj ));
279
+ printf_ln ( _ ( "unreachable %s %s" ) , printable_type (obj ),
280
+ describe_object (obj ));
277
281
return ;
278
282
}
279
283
@@ -291,27 +295,27 @@ static void check_unreachable_object(struct object *obj)
291
295
*/
292
296
if (!(obj -> flags & USED )) {
293
297
if (show_dangling )
294
- printf ( "dangling %s %s\n" , printable_type (obj ),
295
- describe_object (obj ));
298
+ printf_ln ( _ ( "dangling %s %s" ) , printable_type (obj ),
299
+ describe_object (obj ));
296
300
if (write_lost_and_found ) {
297
301
char * filename = git_pathdup ("lost-found/%s/%s" ,
298
302
obj -> type == OBJ_COMMIT ? "commit" : "other" ,
299
303
describe_object (obj ));
300
304
FILE * f ;
301
305
302
306
if (safe_create_leading_directories_const (filename )) {
303
- error ("Could not create lost-found" );
307
+ error (_ ( "could not create lost-found") );
304
308
free (filename );
305
309
return ;
306
310
}
307
311
f = xfopen (filename , "w" );
308
312
if (obj -> type == OBJ_BLOB ) {
309
313
if (stream_blob_to_fd (fileno (f ), & obj -> oid , NULL , 1 ))
310
- die_errno ("Could not write '%s'" , filename );
314
+ die_errno (_ ( "could not write '%s'") , filename );
311
315
} else
312
316
fprintf (f , "%s\n" , describe_object (obj ));
313
317
if (fclose (f ))
314
- die_errno ("Could not finish '%s'" ,
318
+ die_errno (_ ( "could not finish '%s'") ,
315
319
filename );
316
320
free (filename );
317
321
}
@@ -328,7 +332,7 @@ static void check_unreachable_object(struct object *obj)
328
332
static void check_object (struct object * obj )
329
333
{
330
334
if (verbose )
331
- fprintf (stderr , "Checking %s\n" , describe_object (obj ));
335
+ fprintf_ln (stderr , _ ( "Checking %s" ) , describe_object (obj ));
332
336
333
337
if (obj -> flags & REACHABLE )
334
338
check_reachable_object (obj );
@@ -346,7 +350,7 @@ static void check_connectivity(void)
346
350
/* Look up all the requirements, warn about missing objects.. */
347
351
max = get_max_object_index ();
348
352
if (verbose )
349
- fprintf (stderr , "Checking connectivity (%d objects)\n" , max );
353
+ fprintf_ln (stderr , _ ( "Checking connectivity (%d objects)" ) , max );
350
354
351
355
for (i = 0 ; i < max ; i ++ ) {
352
356
struct object * obj = get_indexed_object (i );
@@ -365,11 +369,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
365
369
obj -> flags |= SEEN ;
366
370
367
371
if (verbose )
368
- fprintf (stderr , "Checking %s %s\n" ,
369
- printable_type (obj ), describe_object (obj ));
372
+ fprintf_ln (stderr , _ ( "Checking %s %s" ) ,
373
+ printable_type (obj ), describe_object (obj ));
370
374
371
375
if (fsck_walk (obj , NULL , & fsck_obj_options ))
372
- objerror (obj , "broken links" );
376
+ objerror (obj , _ ( "broken links" ) );
373
377
err = fsck_object (obj , buffer , size , & fsck_obj_options );
374
378
if (err )
375
379
goto out ;
@@ -378,14 +382,15 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
378
382
struct commit * commit = (struct commit * ) obj ;
379
383
380
384
if (!commit -> parents && show_root )
381
- printf ("root %s\n" , describe_object (& commit -> object ));
385
+ printf_ln (_ ("root %s" ),
386
+ describe_object (& commit -> object ));
382
387
}
383
388
384
389
if (obj -> type == OBJ_TAG ) {
385
390
struct tag * tag = (struct tag * ) obj ;
386
391
387
392
if (show_tags && tag -> tagged ) {
388
- printf_ln ("tagged %s %s (%s) in %s" ,
393
+ printf_ln (_ ( "tagged %s %s (%s) in %s" ) ,
389
394
printable_type (tag -> tagged ),
390
395
describe_object (tag -> tagged ),
391
396
tag -> tag ,
@@ -413,7 +418,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
413
418
eaten );
414
419
if (!obj ) {
415
420
errors_found |= ERROR_OBJECT ;
416
- return error ("%s: object corrupt or missing" , oid_to_hex (oid ));
421
+ return error (_ ("%s: object corrupt or missing" ),
422
+ oid_to_hex (oid ));
417
423
}
418
424
obj -> flags &= ~(REACHABLE | SEEN );
419
425
obj -> flags |= HAS_OBJ ;
@@ -437,7 +443,8 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
437
443
obj -> flags |= USED ;
438
444
mark_object_reachable (obj );
439
445
} else if (!is_promisor_object (oid )) {
440
- error ("%s: invalid reflog entry %s" , refname , oid_to_hex (oid ));
446
+ error (_ ("%s: invalid reflog entry %s" ),
447
+ refname , oid_to_hex (oid ));
441
448
errors_found |= ERROR_REACHABLE ;
442
449
}
443
450
}
@@ -450,8 +457,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
450
457
const char * refname = cb_data ;
451
458
452
459
if (verbose )
453
- fprintf (stderr , "Checking reflog %s->%s\n" ,
454
- oid_to_hex (ooid ), oid_to_hex (noid ));
460
+ fprintf_ln (stderr , _ ( "Checking reflog %s->%s" ) ,
461
+ oid_to_hex (ooid ), oid_to_hex (noid ));
455
462
456
463
fsck_handle_reflog_oid (refname , ooid , 0 );
457
464
fsck_handle_reflog_oid (refname , noid , timestamp );
@@ -480,13 +487,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
480
487
default_refs ++ ;
481
488
return 0 ;
482
489
}
483
- error ("%s: invalid sha1 pointer %s" , refname , oid_to_hex (oid ));
490
+ error (_ ("%s: invalid sha1 pointer %s" ),
491
+ refname , oid_to_hex (oid ));
484
492
errors_found |= ERROR_REACHABLE ;
485
493
/* We'll continue with the rest despite the error.. */
486
494
return 0 ;
487
495
}
488
496
if (obj -> type != OBJ_COMMIT && is_branch (refname )) {
489
- error ("%s: not a commit" , refname );
497
+ error (_ ( "%s: not a commit" ) , refname );
490
498
errors_found |= ERROR_REFS ;
491
499
}
492
500
default_refs ++ ;
@@ -520,7 +528,7 @@ static void get_default_heads(void)
520
528
* "show_unreachable" flag.
521
529
*/
522
530
if (!default_refs ) {
523
- fprintf (stderr , "notice: No default references\n" );
531
+ fprintf_ln (stderr , _ ( "notice: No default references" ) );
524
532
show_unreachable = 0 ;
525
533
}
526
534
}
@@ -535,7 +543,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
535
543
536
544
if (read_loose_object (path , oid , & type , & size , & contents ) < 0 ) {
537
545
errors_found |= ERROR_OBJECT ;
538
- error ("%s: object corrupt or missing: %s" ,
546
+ error (_ ( "%s: object corrupt or missing: %s" ) ,
539
547
oid_to_hex (oid ), path );
540
548
return 0 ; /* keep checking other objects */
541
549
}
@@ -548,7 +556,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
548
556
549
557
if (!obj ) {
550
558
errors_found |= ERROR_OBJECT ;
551
- error ("%s: object could not be parsed: %s" ,
559
+ error (_ ( "%s: object could not be parsed: %s" ) ,
552
560
oid_to_hex (oid ), path );
553
561
if (!eaten )
554
562
free (contents );
@@ -568,7 +576,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
568
576
static int fsck_cruft (const char * basename , const char * path , void * data )
569
577
{
570
578
if (!starts_with (basename , "tmp_obj_" ))
571
- fprintf (stderr , "bad sha1 file: %s\n" , path );
579
+ fprintf_ln (stderr , _ ( "bad sha1 file: %s" ) , path );
572
580
return 0 ;
573
581
}
574
582
@@ -583,7 +591,7 @@ static void fsck_object_dir(const char *path)
583
591
struct progress * progress = NULL ;
584
592
585
593
if (verbose )
586
- fprintf (stderr , "Checking object directory\n" );
594
+ fprintf_ln (stderr , _ ( "Checking object directory" ) );
587
595
588
596
if (show_progress )
589
597
progress = start_progress (_ ("Checking object directories" ), 256 );
@@ -599,28 +607,28 @@ static int fsck_head_link(void)
599
607
int null_is_error = 0 ;
600
608
601
609
if (verbose )
602
- fprintf (stderr , "Checking HEAD link\n" );
610
+ fprintf_ln (stderr , _ ( "Checking HEAD link" ) );
603
611
604
612
head_points_at = resolve_ref_unsafe ("HEAD" , 0 , & head_oid , NULL );
605
613
if (!head_points_at ) {
606
614
errors_found |= ERROR_REFS ;
607
- return error ("Invalid HEAD" );
615
+ return error (_ ( "invalid HEAD") );
608
616
}
609
617
if (!strcmp (head_points_at , "HEAD" ))
610
618
/* detached HEAD */
611
619
null_is_error = 1 ;
612
620
else if (!starts_with (head_points_at , "refs/heads/" )) {
613
621
errors_found |= ERROR_REFS ;
614
- return error ("HEAD points to something strange (%s)" ,
622
+ return error (_ ( "HEAD points to something strange (%s)" ) ,
615
623
head_points_at );
616
624
}
617
625
if (is_null_oid (& head_oid )) {
618
626
if (null_is_error ) {
619
627
errors_found |= ERROR_REFS ;
620
- return error ("HEAD: detached HEAD points at nothing" );
628
+ return error (_ ( "HEAD: detached HEAD points at nothing" ) );
621
629
}
622
- fprintf (stderr , "notice: HEAD points to an unborn branch (%s)\n" ,
623
- head_points_at + 11 );
630
+ fprintf_ln (stderr , _ ( "notice: HEAD points to an unborn branch (%s)" ) ,
631
+ head_points_at + 11 );
624
632
}
625
633
return 0 ;
626
634
}
@@ -631,12 +639,12 @@ static int fsck_cache_tree(struct cache_tree *it)
631
639
int err = 0 ;
632
640
633
641
if (verbose )
634
- fprintf (stderr , "Checking cache tree\n" );
642
+ fprintf_ln (stderr , _ ( "Checking cache tree" ) );
635
643
636
644
if (0 <= it -> entry_count ) {
637
645
struct object * obj = parse_object (the_repository , & it -> oid );
638
646
if (!obj ) {
639
- error ("%s: invalid sha1 pointer in cache-tree" ,
647
+ error (_ ( "%s: invalid sha1 pointer in cache-tree" ) ,
640
648
oid_to_hex (& it -> oid ));
641
649
errors_found |= ERROR_REFS ;
642
650
return 1 ;
@@ -647,7 +655,7 @@ static int fsck_cache_tree(struct cache_tree *it)
647
655
obj , xstrdup (":" ));
648
656
mark_object_reachable (obj );
649
657
if (obj -> type != OBJ_TREE )
650
- err |= objerror (obj , "non-tree in cache-tree" );
658
+ err |= objerror (obj , _ ( "non-tree in cache-tree" ) );
651
659
}
652
660
for (i = 0 ; i < it -> subtree_nr ; i ++ )
653
661
err |= fsck_cache_tree (it -> down [i ]-> cache_tree );
@@ -789,7 +797,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
789
797
if (!obj || !(obj -> flags & HAS_OBJ )) {
790
798
if (is_promisor_object (& oid ))
791
799
continue ;
792
- error ("%s: object missing" , oid_to_hex (& oid ));
800
+ error (_ ( "%s: object missing" ) , oid_to_hex (& oid ));
793
801
errors_found |= ERROR_OBJECT ;
794
802
continue ;
795
803
}
@@ -801,7 +809,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
801
809
mark_object_reachable (obj );
802
810
continue ;
803
811
}
804
- error ("invalid parameter: expected sha1, got '%s'" , arg );
812
+ error (_ ( "invalid parameter: expected sha1, got '%s'" ) , arg );
805
813
errors_found |= ERROR_OBJECT ;
806
814
}
807
815
0 commit comments