@@ -40,6 +40,11 @@ static int show_dangling = 1;
40
40
#define ERROR_PACK 04
41
41
#define ERROR_REFS 010
42
42
43
+ static const char * describe_object (struct object * obj )
44
+ {
45
+ return oid_to_hex (& obj -> oid );
46
+ }
47
+
43
48
static int fsck_config (const char * var , const char * value , void * cb )
44
49
{
45
50
if (strcmp (var , "fsck.skiplist" ) == 0 ) {
@@ -67,7 +72,7 @@ static void objreport(struct object *obj, const char *msg_type,
67
72
const char * err )
68
73
{
69
74
fprintf (stderr , "%s in %s %s: %s\n" ,
70
- msg_type , typename (obj -> type ), oid_to_hex ( & obj -> oid ), err );
75
+ msg_type , typename (obj -> type ), describe_object ( obj ), err );
71
76
}
72
77
73
78
static int objerror (struct object * obj , const char * err )
@@ -97,7 +102,7 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
97
102
if (!obj ) {
98
103
/* ... these references to parent->fld are safe here */
99
104
printf ("broken link from %7s %s\n" ,
100
- typename (parent -> type ), oid_to_hex ( & parent -> oid ));
105
+ typename (parent -> type ), describe_object ( parent ));
101
106
printf ("broken link from %7s %s\n" ,
102
107
(type == OBJ_ANY ? "unknown" : typename (type )), "unknown" );
103
108
errors_found |= ERROR_REACHABLE ;
@@ -114,9 +119,9 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
114
119
if (!(obj -> flags & HAS_OBJ )) {
115
120
if (parent && !has_object_file (& obj -> oid )) {
116
121
printf ("broken link from %7s %s\n" ,
117
- typename (parent -> type ), oid_to_hex ( & parent -> oid ));
122
+ typename (parent -> type ), describe_object ( parent ));
118
123
printf (" to %7s %s\n" ,
119
- typename (obj -> type ), oid_to_hex ( & obj -> oid ));
124
+ typename (obj -> type ), describe_object ( obj ));
120
125
errors_found |= ERROR_REACHABLE ;
121
126
}
122
127
return 1 ;
@@ -190,7 +195,8 @@ static void check_reachable_object(struct object *obj)
190
195
return ; /* it is in pack - forget about it */
191
196
if (connectivity_only && has_object_file (& obj -> oid ))
192
197
return ;
193
- printf ("missing %s %s\n" , typename (obj -> type ), oid_to_hex (& obj -> oid ));
198
+ printf ("missing %s %s\n" , typename (obj -> type ),
199
+ describe_object (obj ));
194
200
errors_found |= ERROR_REACHABLE ;
195
201
return ;
196
202
}
@@ -215,7 +221,8 @@ static void check_unreachable_object(struct object *obj)
215
221
* since this is something that is prunable.
216
222
*/
217
223
if (show_unreachable ) {
218
- printf ("unreachable %s %s\n" , typename (obj -> type ), oid_to_hex (& obj -> oid ));
224
+ printf ("unreachable %s %s\n" , typename (obj -> type ),
225
+ describe_object (obj ));
219
226
return ;
220
227
}
221
228
@@ -234,11 +241,11 @@ static void check_unreachable_object(struct object *obj)
234
241
if (!obj -> used ) {
235
242
if (show_dangling )
236
243
printf ("dangling %s %s\n" , typename (obj -> type ),
237
- oid_to_hex ( & obj -> oid ));
244
+ describe_object ( obj ));
238
245
if (write_lost_and_found ) {
239
246
char * filename = git_pathdup ("lost-found/%s/%s" ,
240
247
obj -> type == OBJ_COMMIT ? "commit" : "other" ,
241
- oid_to_hex ( & obj -> oid ));
248
+ describe_object ( obj ));
242
249
FILE * f ;
243
250
244
251
if (safe_create_leading_directories_const (filename )) {
@@ -252,7 +259,7 @@ static void check_unreachable_object(struct object *obj)
252
259
if (stream_blob_to_fd (fileno (f ), obj -> oid .hash , NULL , 1 ))
253
260
die_errno ("Could not write '%s'" , filename );
254
261
} else
255
- fprintf (f , "%s\n" , oid_to_hex ( & obj -> oid ));
262
+ fprintf (f , "%s\n" , describe_object ( obj ));
256
263
if (fclose (f ))
257
264
die_errno ("Could not finish '%s'" ,
258
265
filename );
@@ -271,7 +278,7 @@ static void check_unreachable_object(struct object *obj)
271
278
static void check_object (struct object * obj )
272
279
{
273
280
if (verbose )
274
- fprintf (stderr , "Checking %s\n" , oid_to_hex ( & obj -> oid ));
281
+ fprintf (stderr , "Checking %s\n" , describe_object ( obj ));
275
282
276
283
if (obj -> flags & REACHABLE )
277
284
check_reachable_object (obj );
@@ -307,7 +314,7 @@ static int fsck_obj(struct object *obj)
307
314
308
315
if (verbose )
309
316
fprintf (stderr , "Checking %s %s\n" ,
310
- typename (obj -> type ), oid_to_hex ( & obj -> oid ));
317
+ typename (obj -> type ), describe_object ( obj ));
311
318
312
319
if (fsck_walk (obj , NULL , & fsck_obj_options ))
313
320
objerror (obj , "broken links" );
@@ -326,15 +333,17 @@ static int fsck_obj(struct object *obj)
326
333
free_commit_buffer (commit );
327
334
328
335
if (!commit -> parents && show_root )
329
- printf ("root %s\n" , oid_to_hex (& commit -> object . oid ));
336
+ printf ("root %s\n" , describe_object (& commit -> object ));
330
337
}
331
338
332
339
if (obj -> type == OBJ_TAG ) {
333
340
struct tag * tag = (struct tag * ) obj ;
334
341
335
342
if (show_tags && tag -> tagged ) {
336
- printf ("tagged %s %s" , typename (tag -> tagged -> type ), oid_to_hex (& tag -> tagged -> oid ));
337
- printf (" (%s) in %s\n" , tag -> tag , oid_to_hex (& tag -> object .oid ));
343
+ printf ("tagged %s %s" , typename (tag -> tagged -> type ),
344
+ describe_object (tag -> tagged ));
345
+ printf (" (%s) in %s\n" , tag -> tag ,
346
+ describe_object (& tag -> object ));
338
347
}
339
348
}
340
349
0 commit comments