@@ -84,7 +84,7 @@ static char *replace_idents_using_mailmap(char *object_buf, size_t *size)
8484
8585static int filter_object (const char * path , unsigned mode ,
8686 const struct object_id * oid ,
87- char * * buf , unsigned long * size )
87+ char * * buf , size_t * size )
8888{
8989 enum object_type type ;
9090
@@ -120,7 +120,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
120120 struct object_id oid ;
121121 enum object_type type ;
122122 char * buf ;
123- unsigned long size ;
123+ size_t size ;
124124 struct object_context obj_context = {0 };
125125 struct object_info oi = OBJECT_INFO_INIT ;
126126 unsigned flags = OBJECT_INFO_LOOKUP_REPLACE ;
@@ -166,7 +166,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
166166 if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG )) {
167167 size_t s = size ;
168168 buf = replace_idents_using_mailmap (buf , & s );
169- size = cast_size_t_to_ulong ( s ) ;
169+ size = s ;
170170 }
171171
172172 printf ("%" PRIuMAX "\n" , (uintmax_t )size );
@@ -188,9 +188,15 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
188188 break ;
189189
190190 case 'c' :
191- if (textconv_object (the_repository , path , obj_context .mode ,
192- & oid , 1 , & buf , & size ))
191+ {
192+ unsigned long size_ul = 0 ;
193+ int textconv_ret = textconv_object (the_repository , path ,
194+ obj_context .mode , & oid , 1 ,
195+ & buf , & size_ul );
196+ size = size_ul ;
197+ if (textconv_ret )
193198 break ;
199+ }
194200 /* else fallthrough */
195201
196202 case 'p' :
@@ -219,7 +225,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
219225 if (use_mailmap ) {
220226 size_t s = size ;
221227 buf = replace_idents_using_mailmap (buf , & s );
222- size = cast_size_t_to_ulong ( s ) ;
228+ size = s ;
223229 }
224230
225231 /* otherwise just spit out the data */
@@ -266,7 +272,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
266272 if (use_mailmap ) {
267273 size_t s = size ;
268274 buf = replace_idents_using_mailmap (buf , & s );
269- size = cast_size_t_to_ulong ( s ) ;
275+ size = s ;
270276 }
271277 break ;
272278 }
@@ -288,7 +294,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
288294struct expand_data {
289295 struct object_id oid ;
290296 enum object_type type ;
291- unsigned long size ;
297+ size_t size ;
292298 unsigned short mode ;
293299 off_t disk_size ;
294300 const char * rest ;
@@ -404,7 +410,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
404410 fflush (stdout );
405411 if (opt -> transform_mode ) {
406412 char * contents ;
407- unsigned long size ;
413+ size_t size ;
408414
409415 if (!data -> rest )
410416 die ("missing path for '%s'" , oid_to_hex (oid ));
@@ -416,9 +422,12 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
416422 oid_to_hex (oid ), data -> rest );
417423 } else if (opt -> transform_mode == 'c' ) {
418424 enum object_type type ;
419- if (!textconv_object (the_repository ,
420- data -> rest , 0100644 , oid ,
421- 1 , & contents , & size ))
425+ unsigned long size_ul = 0 ;
426+ if (textconv_object (the_repository ,
427+ data -> rest , 0100644 , oid ,
428+ 1 , & contents , & size_ul ))
429+ size = size_ul ;
430+ else
422431 contents = odb_read_object (the_repository -> objects ,
423432 oid , & type , & size );
424433 if (!contents )
@@ -434,7 +443,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
434443 }
435444 else {
436445 enum object_type type ;
437- unsigned long size ;
446+ size_t size ;
438447 void * contents ;
439448
440449 contents = odb_read_object (the_repository -> objects , oid ,
@@ -445,7 +454,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
445454 if (use_mailmap ) {
446455 size_t s = size ;
447456 contents = replace_idents_using_mailmap (contents , & s );
448- size = cast_size_t_to_ulong ( s ) ;
457+ size = s ;
449458 }
450459
451460 if (type != data -> type )
@@ -554,7 +563,7 @@ static void batch_object_write(const char *obj_name,
554563 if (!buf )
555564 die (_ ("unable to read %s" ), oid_to_hex (& data -> oid ));
556565 buf = replace_idents_using_mailmap (buf , & s );
557- data -> size = cast_size_t_to_ulong ( s ) ;
566+ data -> size = s ;
558567
559568 free (buf );
560569 }
0 commit comments