1- #define USE_THE_REPOSITORY_VARIABLE
21#include "builtin.h"
32#include "gettext.h"
43#include "hex.h"
@@ -66,14 +65,14 @@ static const char *describe_object(const struct object_id *oid)
6665 return fsck_describe_object (& fsck_walk_options , oid );
6766}
6867
69- static const char * printable_type (const struct object_id * oid ,
68+ static const char * printable_type (struct repository * repo ,
69+ const struct object_id * oid ,
7070 enum object_type type )
7171{
7272 const char * ret ;
7373
7474 if (type == OBJ_NONE )
75- type = odb_read_object_info (the_repository -> objects ,
76- oid , NULL );
75+ type = odb_read_object_info (repo -> objects , oid , NULL );
7776
7877 ret = type_name (type );
7978 if (!ret )
@@ -82,17 +81,17 @@ static const char *printable_type(const struct object_id *oid,
8281 return ret ;
8382}
8483
85- static int objerror (struct object * obj , const char * err )
84+ static int objerror (struct repository * repo , struct object * obj , const char * err )
8685{
8786 errors_found |= ERROR_OBJECT ;
8887 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
8988 fprintf_ln (stderr , _ ("error in %s %s: %s" ),
90- printable_type (& obj -> oid , obj -> type ),
89+ printable_type (repo , & obj -> oid , obj -> type ),
9190 describe_object (& obj -> oid ), err );
9291 return -1 ;
9392}
9493
95- static int fsck_objects_error_func (struct fsck_options * o UNUSED ,
94+ static int fsck_objects_error_func (struct fsck_options * o ,
9695 void * fsck_report ,
9796 enum fsck_msg_type msg_type ,
9897 enum fsck_msg_id msg_id UNUSED ,
@@ -106,13 +105,13 @@ static int fsck_objects_error_func(struct fsck_options *o UNUSED,
106105 case FSCK_WARN :
107106 /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
108107 fprintf_ln (stderr , _ ("warning in %s %s: %s" ),
109- printable_type (oid , object_type ),
108+ printable_type (o -> repo , oid , object_type ),
110109 describe_object (oid ), message );
111110 return 0 ;
112111 case FSCK_ERROR :
113112 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
114113 fprintf_ln (stderr , _ ("error in %s %s: %s" ),
115- printable_type (oid , object_type ),
114+ printable_type (o -> repo , oid , object_type ),
116115 describe_object (oid ), message );
117116 return 1 ;
118117 default :
@@ -136,7 +135,7 @@ static int mark_object(struct object *obj, enum object_type type,
136135 if (!obj ) {
137136 /* ... these references to parent->fld are safe here */
138137 printf_ln (_ ("broken link from %7s %s" ),
139- printable_type (& parent -> oid , parent -> type ),
138+ printable_type (options -> repo , & parent -> oid , parent -> type ),
140139 describe_object (& parent -> oid ));
141140 printf_ln (_ ("broken link from %7s %s" ),
142141 (type == OBJ_ANY ? _ ("unknown" ) : type_name (type )),
@@ -147,7 +146,7 @@ static int mark_object(struct object *obj, enum object_type type,
147146
148147 if (type != OBJ_ANY && obj -> type != type )
149148 /* ... and the reference to parent is safe here */
150- objerror (parent , _ ("wrong object type in link" ));
149+ objerror (options -> repo , parent , _ ("wrong object type in link" ));
151150
152151 if (obj -> flags & REACHABLE )
153152 return 0 ;
@@ -166,9 +165,9 @@ static int mark_object(struct object *obj, enum object_type type,
166165 HAS_OBJECT_RECHECK_PACKED )) {
167166 printf_ln (_ ("broken link from %7s %s\n"
168167 " to %7s %s" ),
169- printable_type (& parent -> oid , parent -> type ),
168+ printable_type (options -> repo , & parent -> oid , parent -> type ),
170169 describe_object (& parent -> oid ),
171- printable_type (& obj -> oid , obj -> type ),
170+ printable_type (options -> repo , & obj -> oid , obj -> type ),
172171 describe_object (& obj -> oid ));
173172 errors_found |= ERROR_REACHABLE ;
174173 }
@@ -269,7 +268,7 @@ static void check_reachable_object(struct repository *repo, struct object *obj)
269268 if (has_object_pack (repo , & obj -> oid ))
270269 return ; /* it is in pack - forget about it */
271270 printf_ln (_ ("missing %s %s" ),
272- printable_type (& obj -> oid , obj -> type ),
271+ printable_type (repo , & obj -> oid , obj -> type ),
273272 describe_object (& obj -> oid ));
274273 errors_found |= ERROR_REACHABLE ;
275274 return ;
@@ -296,7 +295,7 @@ static void check_unreachable_object(struct repository *repo, struct object *obj
296295 */
297296 if (show_unreachable ) {
298297 printf_ln (_ ("unreachable %s %s" ),
299- printable_type (& obj -> oid , obj -> type ),
298+ printable_type (repo , & obj -> oid , obj -> type ),
300299 describe_object (& obj -> oid ));
301300 return ;
302301 }
@@ -316,7 +315,7 @@ static void check_unreachable_object(struct repository *repo, struct object *obj
316315 if (!(obj -> flags & USED )) {
317316 if (show_dangling )
318317 printf_ln (_ ("dangling %s %s" ),
319- printable_type (& obj -> oid , obj -> type ),
318+ printable_type (repo , & obj -> oid , obj -> type ),
320319 describe_object (& obj -> oid ));
321320 if (write_lost_and_found ) {
322321 char * filename = repo_git_path (repo , "lost-found/%s/%s" ,
@@ -402,7 +401,8 @@ static void check_connectivity(struct repository *repo)
402401 }
403402}
404403
405- static int fsck_obj (struct object * obj , void * buffer , unsigned long size )
404+ static int fsck_obj (struct repository * repo ,
405+ struct object * obj , void * buffer , unsigned long size )
406406{
407407 int err ;
408408
@@ -412,11 +412,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
412412
413413 if (verbose )
414414 fprintf_ln (stderr , _ ("Checking %s %s" ),
415- printable_type (& obj -> oid , obj -> type ),
415+ printable_type (repo , & obj -> oid , obj -> type ),
416416 describe_object (& obj -> oid ));
417417
418418 if (fsck_walk (obj , NULL , & fsck_obj_options ))
419- objerror (obj , _ ("broken links" ));
419+ objerror (repo , obj , _ ("broken links" ));
420420 err = fsck_object (obj , buffer , size , & fsck_obj_options );
421421 if (err )
422422 goto out ;
@@ -434,7 +434,7 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
434434
435435 if (show_tags && tag -> tagged ) {
436436 printf_ln (_ ("tagged %s %s (%s) in %s" ),
437- printable_type (& tag -> tagged -> oid , tag -> tagged -> type ),
437+ printable_type (repo , & tag -> tagged -> oid , tag -> tagged -> type ),
438438 describe_object (& tag -> tagged -> oid ),
439439 tag -> tag ,
440440 describe_object (& tag -> object .oid ));
@@ -465,7 +465,7 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,
465465 }
466466 obj -> flags &= ~(REACHABLE | SEEN );
467467 obj -> flags |= HAS_OBJ ;
468- return fsck_obj (obj , buffer , size );
468+ return fsck_obj (repo , obj , buffer , size );
469469}
470470
471471static int default_refs ;
@@ -765,7 +765,7 @@ static int fsck_loose(const struct object_id *oid, const char *path,
765765
766766 obj -> flags &= ~(REACHABLE | SEEN );
767767 obj -> flags |= HAS_OBJ ;
768- if (fsck_obj (obj , contents , size ))
768+ if (fsck_obj (data -> repo , obj , contents , size ))
769769 errors_found |= ERROR_OBJECT ;
770770
771771 if (!eaten )
@@ -830,7 +830,7 @@ static int fsck_cache_tree(struct repository *repo, struct cache_tree *it, const
830830 fsck_put_object_name (& fsck_walk_options , & it -> oid , ":" );
831831 mark_object_reachable (obj );
832832 if (obj -> type != OBJ_TREE )
833- err |= objerror (obj , _ ("non-tree in cache-tree" ));
833+ err |= objerror (repo , obj , _ ("non-tree in cache-tree" ));
834834 }
835835 for (i = 0 ; i < it -> subtree_nr ; i ++ )
836836 err |= fsck_cache_tree (repo , it -> down [i ]-> cache_tree , index_path );
0 commit comments