@@ -50,6 +50,13 @@ static int filter_object(const char *path, unsigned mode,
5050 return 0 ;
5151}
5252
53+ static int stream_blob (const struct object_id * oid )
54+ {
55+ if (stream_blob_to_fd (1 , oid , NULL , 0 ))
56+ die ("unable to stream %s to stdout" , oid_to_hex (oid ));
57+ return 0 ;
58+ }
59+
5360static int cat_one_file (int opt , const char * exp_type , const char * obj_name ,
5461 int unknown_type )
5562{
@@ -131,7 +138,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
131138 }
132139
133140 if (type == OBJ_BLOB )
134- return stream_blob_to_fd ( 1 , & oid , NULL , 0 );
141+ return stream_blob ( & oid );
135142 buf = read_object_file (& oid , & type , & size );
136143 if (!buf )
137144 die ("Cannot read object %s" , obj_name );
@@ -154,7 +161,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
154161 oidcpy (& blob_oid , & oid );
155162
156163 if (oid_object_info (the_repository , & blob_oid , NULL ) == OBJ_BLOB )
157- return stream_blob_to_fd ( 1 , & blob_oid , NULL , 0 );
164+ return stream_blob ( & blob_oid );
158165 /*
159166 * we attempted to dereference a tag to a blob
160167 * and failed; there may be new dereference
@@ -317,8 +324,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
317324 BUG ("invalid cmdmode: %c" , opt -> cmdmode );
318325 batch_write (opt , contents , size );
319326 free (contents );
320- } else if (stream_blob_to_fd (1 , oid , NULL , 0 ) < 0 )
321- die ("unable to stream %s to stdout" , oid_to_hex (oid ));
327+ } else {
328+ stream_blob (oid );
329+ }
322330 }
323331 else {
324332 enum object_type type ;
0 commit comments