@@ -538,7 +538,7 @@ static int grep_submodule_launch(struct grep_opt *opt,
538
538
int status , i ;
539
539
const char * end_of_base ;
540
540
const char * name ;
541
- struct work_item * w = opt -> output_priv ;
541
+ struct strbuf child_output = STRBUF_INIT ;
542
542
543
543
end_of_base = strchr (gs -> name , ':' );
544
544
if (gs -> identifier && end_of_base )
@@ -593,14 +593,16 @@ static int grep_submodule_launch(struct grep_opt *opt,
593
593
* child process. A '0' indicates a hit, a '1' indicates no hit and
594
594
* anything else is an error.
595
595
*/
596
- status = capture_command (& cp , & w -> out , 0 );
596
+ status = capture_command (& cp , & child_output , 0 );
597
597
if (status && (status != 1 )) {
598
598
/* flush the buffer */
599
- write_or_die (1 , w -> out .buf , w -> out .len );
599
+ write_or_die (1 , child_output .buf , child_output .len );
600
600
die ("process for submodule '%s' failed with exit code: %d" ,
601
601
gs -> name , status );
602
602
}
603
603
604
+ opt -> output (opt , child_output .buf , child_output .len );
605
+ strbuf_release (& child_output );
604
606
/* invert the return code to make a hit equal to 1 */
605
607
return !status ;
606
608
}
@@ -641,19 +643,14 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
641
643
} else
642
644
#endif
643
645
{
644
- struct work_item w ;
646
+ struct grep_source gs ;
645
647
int hit ;
646
648
647
- grep_source_init (& w . source , GREP_SOURCE_SUBMODULE ,
649
+ grep_source_init (& gs , GREP_SOURCE_SUBMODULE ,
648
650
filename , path , sha1 );
649
- strbuf_init (& w .out , 0 );
650
- opt -> output_priv = & w ;
651
- hit = grep_submodule_launch (opt , & w .source );
651
+ hit = grep_submodule_launch (opt , & gs );
652
652
653
- write_or_die (1 , w .out .buf , w .out .len );
654
-
655
- grep_source_clear (& w .source );
656
- strbuf_release (& w .out );
653
+ grep_source_clear (& gs );
657
654
return hit ;
658
655
}
659
656
}
0 commit comments