@@ -85,7 +85,7 @@ static const char *printable_type(struct object *obj)
8585
8686 ret = type_name (obj -> type );
8787 if (!ret )
88- ret = "unknown" ;
88+ ret = _ ( "unknown" ) ;
8989
9090 return ret ;
9191}
@@ -116,7 +116,8 @@ static int fsck_config(const char *var, const char *value, void *cb)
116116static int objerror (struct object * obj , const char * err )
117117{
118118 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" ),
120121 printable_type (obj ), describe_object (obj ), err );
121122 return -1 ;
122123}
@@ -126,11 +127,13 @@ static int fsck_error_func(struct fsck_options *o,
126127{
127128 switch (type ) {
128129 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" ),
130132 printable_type (obj ), describe_object (obj ), message );
131133 return 0 ;
132134 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" ),
134137 printable_type (obj ), describe_object (obj ), message );
135138 return 1 ;
136139 default :
@@ -151,17 +154,18 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
151154 */
152155 if (!obj ) {
153156 /* ... 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" ));
158162 errors_found |= ERROR_REACHABLE ;
159163 return 1 ;
160164 }
161165
162166 if (type != OBJ_ANY && obj -> type != type )
163167 /* ... and the reference to parent is safe here */
164- objerror (parent , "wrong object type in link" );
168+ objerror (parent , _ ( "wrong object type in link" ) );
165169
166170 if (obj -> flags & REACHABLE )
167171 return 0 ;
@@ -177,8 +181,8 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
177181
178182 if (!(obj -> flags & HAS_OBJ )) {
179183 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" ) ,
182186 printable_type (parent ),
183187 describe_object (parent ),
184188 printable_type (obj ),
@@ -246,8 +250,8 @@ static void check_reachable_object(struct object *obj)
246250 return ;
247251 if (has_object_pack (& obj -> oid ))
248252 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 ));
251255 errors_found |= ERROR_REACHABLE ;
252256 return ;
253257 }
@@ -272,8 +276,8 @@ static void check_unreachable_object(struct object *obj)
272276 * since this is something that is prunable.
273277 */
274278 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 ));
277281 return ;
278282 }
279283
@@ -291,27 +295,27 @@ static void check_unreachable_object(struct object *obj)
291295 */
292296 if (!(obj -> flags & USED )) {
293297 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 ));
296300 if (write_lost_and_found ) {
297301 char * filename = git_pathdup ("lost-found/%s/%s" ,
298302 obj -> type == OBJ_COMMIT ? "commit" : "other" ,
299303 describe_object (obj ));
300304 FILE * f ;
301305
302306 if (safe_create_leading_directories_const (filename )) {
303- error ("Could not create lost-found" );
307+ error (_ ( "could not create lost-found") );
304308 free (filename );
305309 return ;
306310 }
307311 f = xfopen (filename , "w" );
308312 if (obj -> type == OBJ_BLOB ) {
309313 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 );
311315 } else
312316 fprintf (f , "%s\n" , describe_object (obj ));
313317 if (fclose (f ))
314- die_errno ("Could not finish '%s'" ,
318+ die_errno (_ ( "could not finish '%s'") ,
315319 filename );
316320 free (filename );
317321 }
@@ -328,7 +332,7 @@ static void check_unreachable_object(struct object *obj)
328332static void check_object (struct object * obj )
329333{
330334 if (verbose )
331- fprintf (stderr , "Checking %s\n" , describe_object (obj ));
335+ fprintf_ln (stderr , _ ( "Checking %s" ) , describe_object (obj ));
332336
333337 if (obj -> flags & REACHABLE )
334338 check_reachable_object (obj );
@@ -346,7 +350,7 @@ static void check_connectivity(void)
346350 /* Look up all the requirements, warn about missing objects.. */
347351 max = get_max_object_index ();
348352 if (verbose )
349- fprintf (stderr , "Checking connectivity (%d objects)\n" , max );
353+ fprintf_ln (stderr , _ ( "Checking connectivity (%d objects)" ) , max );
350354
351355 for (i = 0 ; i < max ; i ++ ) {
352356 struct object * obj = get_indexed_object (i );
@@ -365,11 +369,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
365369 obj -> flags |= SEEN ;
366370
367371 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 ));
370374
371375 if (fsck_walk (obj , NULL , & fsck_obj_options ))
372- objerror (obj , "broken links" );
376+ objerror (obj , _ ( "broken links" ) );
373377 err = fsck_object (obj , buffer , size , & fsck_obj_options );
374378 if (err )
375379 goto out ;
@@ -378,14 +382,15 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
378382 struct commit * commit = (struct commit * ) obj ;
379383
380384 if (!commit -> parents && show_root )
381- printf ("root %s\n" , describe_object (& commit -> object ));
385+ printf_ln (_ ("root %s" ),
386+ describe_object (& commit -> object ));
382387 }
383388
384389 if (obj -> type == OBJ_TAG ) {
385390 struct tag * tag = (struct tag * ) obj ;
386391
387392 if (show_tags && tag -> tagged ) {
388- printf_ln ("tagged %s %s (%s) in %s" ,
393+ printf_ln (_ ( "tagged %s %s (%s) in %s" ) ,
389394 printable_type (tag -> tagged ),
390395 describe_object (tag -> tagged ),
391396 tag -> tag ,
@@ -413,7 +418,8 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
413418 eaten );
414419 if (!obj ) {
415420 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 ));
417423 }
418424 obj -> flags &= ~(REACHABLE | SEEN );
419425 obj -> flags |= HAS_OBJ ;
@@ -437,7 +443,8 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
437443 obj -> flags |= USED ;
438444 mark_object_reachable (obj );
439445 } 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 ));
441448 errors_found |= ERROR_REACHABLE ;
442449 }
443450 }
@@ -450,8 +457,8 @@ static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid
450457 const char * refname = cb_data ;
451458
452459 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 ));
455462
456463 fsck_handle_reflog_oid (refname , ooid , 0 );
457464 fsck_handle_reflog_oid (refname , noid , timestamp );
@@ -480,13 +487,14 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid,
480487 default_refs ++ ;
481488 return 0 ;
482489 }
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 ));
484492 errors_found |= ERROR_REACHABLE ;
485493 /* We'll continue with the rest despite the error.. */
486494 return 0 ;
487495 }
488496 if (obj -> type != OBJ_COMMIT && is_branch (refname )) {
489- error ("%s: not a commit" , refname );
497+ error (_ ( "%s: not a commit" ) , refname );
490498 errors_found |= ERROR_REFS ;
491499 }
492500 default_refs ++ ;
@@ -520,7 +528,7 @@ static void get_default_heads(void)
520528 * "show_unreachable" flag.
521529 */
522530 if (!default_refs ) {
523- fprintf (stderr , "notice: No default references\n" );
531+ fprintf_ln (stderr , _ ( "notice: No default references" ) );
524532 show_unreachable = 0 ;
525533 }
526534}
@@ -535,7 +543,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
535543
536544 if (read_loose_object (path , oid , & type , & size , & contents ) < 0 ) {
537545 errors_found |= ERROR_OBJECT ;
538- error ("%s: object corrupt or missing: %s" ,
546+ error (_ ( "%s: object corrupt or missing: %s" ) ,
539547 oid_to_hex (oid ), path );
540548 return 0 ; /* keep checking other objects */
541549 }
@@ -548,7 +556,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
548556
549557 if (!obj ) {
550558 errors_found |= ERROR_OBJECT ;
551- error ("%s: object could not be parsed: %s" ,
559+ error (_ ( "%s: object could not be parsed: %s" ) ,
552560 oid_to_hex (oid ), path );
553561 if (!eaten )
554562 free (contents );
@@ -568,7 +576,7 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
568576static int fsck_cruft (const char * basename , const char * path , void * data )
569577{
570578 if (!starts_with (basename , "tmp_obj_" ))
571- fprintf (stderr , "bad sha1 file: %s\n" , path );
579+ fprintf_ln (stderr , _ ( "bad sha1 file: %s" ) , path );
572580 return 0 ;
573581}
574582
@@ -583,7 +591,7 @@ static void fsck_object_dir(const char *path)
583591 struct progress * progress = NULL ;
584592
585593 if (verbose )
586- fprintf (stderr , "Checking object directory\n" );
594+ fprintf_ln (stderr , _ ( "Checking object directory" ) );
587595
588596 if (show_progress )
589597 progress = start_progress (_ ("Checking object directories" ), 256 );
@@ -599,28 +607,28 @@ static int fsck_head_link(void)
599607 int null_is_error = 0 ;
600608
601609 if (verbose )
602- fprintf (stderr , "Checking HEAD link\n" );
610+ fprintf_ln (stderr , _ ( "Checking HEAD link" ) );
603611
604612 head_points_at = resolve_ref_unsafe ("HEAD" , 0 , & head_oid , NULL );
605613 if (!head_points_at ) {
606614 errors_found |= ERROR_REFS ;
607- return error ("Invalid HEAD" );
615+ return error (_ ( "invalid HEAD") );
608616 }
609617 if (!strcmp (head_points_at , "HEAD" ))
610618 /* detached HEAD */
611619 null_is_error = 1 ;
612620 else if (!starts_with (head_points_at , "refs/heads/" )) {
613621 errors_found |= ERROR_REFS ;
614- return error ("HEAD points to something strange (%s)" ,
622+ return error (_ ( "HEAD points to something strange (%s)" ) ,
615623 head_points_at );
616624 }
617625 if (is_null_oid (& head_oid )) {
618626 if (null_is_error ) {
619627 errors_found |= ERROR_REFS ;
620- return error ("HEAD: detached HEAD points at nothing" );
628+ return error (_ ( "HEAD: detached HEAD points at nothing" ) );
621629 }
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 );
624632 }
625633 return 0 ;
626634}
@@ -631,12 +639,12 @@ static int fsck_cache_tree(struct cache_tree *it)
631639 int err = 0 ;
632640
633641 if (verbose )
634- fprintf (stderr , "Checking cache tree\n" );
642+ fprintf_ln (stderr , _ ( "Checking cache tree" ) );
635643
636644 if (0 <= it -> entry_count ) {
637645 struct object * obj = parse_object (the_repository , & it -> oid );
638646 if (!obj ) {
639- error ("%s: invalid sha1 pointer in cache-tree" ,
647+ error (_ ( "%s: invalid sha1 pointer in cache-tree" ) ,
640648 oid_to_hex (& it -> oid ));
641649 errors_found |= ERROR_REFS ;
642650 return 1 ;
@@ -647,7 +655,7 @@ static int fsck_cache_tree(struct cache_tree *it)
647655 obj , xstrdup (":" ));
648656 mark_object_reachable (obj );
649657 if (obj -> type != OBJ_TREE )
650- err |= objerror (obj , "non-tree in cache-tree" );
658+ err |= objerror (obj , _ ( "non-tree in cache-tree" ) );
651659 }
652660 for (i = 0 ; i < it -> subtree_nr ; i ++ )
653661 err |= fsck_cache_tree (it -> down [i ]-> cache_tree );
@@ -789,7 +797,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
789797 if (!obj || !(obj -> flags & HAS_OBJ )) {
790798 if (is_promisor_object (& oid ))
791799 continue ;
792- error ("%s: object missing" , oid_to_hex (& oid ));
800+ error (_ ( "%s: object missing" ) , oid_to_hex (& oid ));
793801 errors_found |= ERROR_OBJECT ;
794802 continue ;
795803 }
@@ -801,7 +809,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
801809 mark_object_reachable (obj );
802810 continue ;
803811 }
804- error ("invalid parameter: expected sha1, got '%s'" , arg );
812+ error (_ ( "invalid parameter: expected sha1, got '%s'" ) , arg );
805813 errors_found |= ERROR_OBJECT ;
806814 }
807815
0 commit comments