2020#include "string-list.h"
2121#include "parse-options.h"
2222#include "branch.h"
23+ #include "streaming.h"
2324
2425/* Set a default date-time format for git log ("log.date" config variable) */
2526static const char * default_date_mode = NULL ;
@@ -381,8 +382,13 @@ static void show_tagger(char *buf, int len, struct rev_info *rev)
381382 strbuf_release (& out );
382383}
383384
384- static int show_object (const unsigned char * sha1 , int show_tag_object ,
385- struct rev_info * rev )
385+ static int show_blob_object (const unsigned char * sha1 , struct rev_info * rev )
386+ {
387+ fflush (stdout );
388+ return stream_blob_to_fd (1 , sha1 , NULL , 0 );
389+ }
390+
391+ static int show_tag_object (const unsigned char * sha1 , struct rev_info * rev )
386392{
387393 unsigned long size ;
388394 enum object_type type ;
@@ -392,16 +398,16 @@ static int show_object(const unsigned char *sha1, int show_tag_object,
392398 if (!buf )
393399 return error (_ ("Could not read object %s" ), sha1_to_hex (sha1 ));
394400
395- if ( show_tag_object )
396- while (offset < size && buf [offset ] != '\n' ) {
397- int new_offset = offset + 1 ;
398- while (new_offset < size && buf [new_offset ++ ] != '\n' )
399- ; /* do nothing */
400- if (!prefixcmp (buf + offset , "tagger " ))
401- show_tagger (buf + offset + 7 ,
402- new_offset - offset - 7 , rev );
403- offset = new_offset ;
404- }
401+ assert ( type == OBJ_TAG );
402+ while (offset < size && buf [offset ] != '\n' ) {
403+ int new_offset = offset + 1 ;
404+ while (new_offset < size && buf [new_offset ++ ] != '\n' )
405+ ; /* do nothing */
406+ if (!prefixcmp (buf + offset , "tagger " ))
407+ show_tagger (buf + offset + 7 ,
408+ new_offset - offset - 7 , rev );
409+ offset = new_offset ;
410+ }
405411
406412 if (offset < size )
407413 fwrite (buf + offset , size - offset , 1 , stdout );
@@ -459,7 +465,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
459465 const char * name = objects [i ].name ;
460466 switch (o -> type ) {
461467 case OBJ_BLOB :
462- ret = show_object (o -> sha1 , 0 , NULL );
468+ ret = show_blob_object (o -> sha1 , NULL );
463469 break ;
464470 case OBJ_TAG : {
465471 struct tag * t = (struct tag * )o ;
@@ -470,7 +476,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
470476 diff_get_color_opt (& rev .diffopt , DIFF_COMMIT ),
471477 t -> tag ,
472478 diff_get_color_opt (& rev .diffopt , DIFF_RESET ));
473- ret = show_object (o -> sha1 , 1 , & rev );
479+ ret = show_tag_object (o -> sha1 , & rev );
474480 rev .shown_one = 1 ;
475481 if (ret )
476482 break ;
0 commit comments