@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
5858 if (strbuf_getline (buffer , helper , '\n' ) == EOF ) {
5959 if (debug )
6060 fprintf (stderr , "Debug: Remote helper quit.\n" );
61- return 1 ;
61+ exit ( 128 ) ;
6262 }
6363
6464 if (debug )
@@ -71,6 +71,12 @@ static int recvline(struct helper_data *helper, struct strbuf *buffer)
7171 return recvline_fh (helper -> out , buffer , helper -> name );
7272}
7373
74+ static void xchgline (struct helper_data * helper , struct strbuf * buffer )
75+ {
76+ sendline (helper , buffer );
77+ recvline (helper , buffer );
78+ }
79+
7480static void write_constant (int fd , const char * str )
7581{
7682 if (debug )
@@ -157,8 +163,7 @@ static struct child_process *get_helper(struct transport *transport)
157163 while (1 ) {
158164 const char * capname ;
159165 int mandatory = 0 ;
160- if (recvline (data , & buf ))
161- exit (128 );
166+ recvline (data , & buf );
162167
163168 if (!* buf .buf )
164169 break ;
@@ -195,9 +200,15 @@ static struct child_process *get_helper(struct transport *transport)
195200 } else if (!strcmp (capname , "signed-tags" )) {
196201 data -> signed_tags = 1 ;
197202 } else if (starts_with (capname , "export-marks " )) {
198- data -> export_marks = xstrdup (capname + strlen ("export-marks " ));
203+ struct strbuf arg = STRBUF_INIT ;
204+ strbuf_addstr (& arg , "--export-marks=" );
205+ strbuf_addstr (& arg , capname + strlen ("export-marks " ));
206+ data -> export_marks = strbuf_detach (& arg , NULL );
199207 } else if (starts_with (capname , "import-marks" )) {
200- data -> import_marks = xstrdup (capname + strlen ("import-marks " ));
208+ struct strbuf arg = STRBUF_INIT ;
209+ strbuf_addstr (& arg , "--import-marks=" );
210+ strbuf_addstr (& arg , capname + strlen ("import-marks " ));
211+ data -> import_marks = strbuf_detach (& arg , NULL );
201212 } else if (starts_with (capname , "no-private-update" )) {
202213 data -> no_private_update = 1 ;
203214 } else if (mandatory ) {
@@ -296,9 +307,7 @@ static int set_helper_option(struct transport *transport,
296307 quote_c_style (value , & buf , NULL , 0 );
297308 strbuf_addch (& buf , '\n' );
298309
299- sendline (data , & buf );
300- if (recvline (data , & buf ))
301- exit (128 );
310+ xchgline (data , & buf );
302311
303312 if (!strcmp (buf .buf , "ok" ))
304313 ret = 0 ;
@@ -370,8 +379,7 @@ static int fetch_with_fetch(struct transport *transport,
370379 sendline (data , & buf );
371380
372381 while (1 ) {
373- if (recvline (data , & buf ))
374- exit (128 );
382+ recvline (data , & buf );
375383
376384 if (starts_with (buf .buf , "lock " )) {
377385 const char * name = buf .buf + 5 ;
@@ -422,8 +430,6 @@ static int get_exporter(struct transport *transport,
422430 struct helper_data * data = transport -> data ;
423431 struct child_process * helper = get_helper (transport );
424432 int argc = 0 , i ;
425- struct strbuf tmp = STRBUF_INIT ;
426-
427433 memset (fastexport , 0 , sizeof (* fastexport ));
428434
429435 /* we need to duplicate helper->in because we want to use it after
@@ -434,14 +440,10 @@ static int get_exporter(struct transport *transport,
434440 fastexport -> argv [argc ++ ] = "--use-done-feature" ;
435441 fastexport -> argv [argc ++ ] = data -> signed_tags ?
436442 "--signed-tags=verbatim" : "--signed-tags=warn-strip" ;
437- if (data -> export_marks ) {
438- strbuf_addf (& tmp , "--export-marks=%s.tmp" , data -> export_marks );
439- fastexport -> argv [argc ++ ] = strbuf_detach (& tmp , NULL );
440- }
441- if (data -> import_marks ) {
442- strbuf_addf (& tmp , "--import-marks=%s" , data -> import_marks );
443- fastexport -> argv [argc ++ ] = strbuf_detach (& tmp , NULL );
444- }
443+ if (data -> export_marks )
444+ fastexport -> argv [argc ++ ] = data -> export_marks ;
445+ if (data -> import_marks )
446+ fastexport -> argv [argc ++ ] = data -> import_marks ;
445447
446448 for (i = 0 ; i < revlist_args -> nr ; i ++ )
447449 fastexport -> argv [argc ++ ] = revlist_args -> items [i ].string ;
@@ -561,9 +563,7 @@ static int process_connect_service(struct transport *transport,
561563 goto exit ;
562564
563565 sendline (data , & cmdbuf );
564- if (recvline_fh (input , & cmdbuf , name ))
565- exit (128 );
566-
566+ recvline_fh (input , & cmdbuf , name );
567567 if (!strcmp (cmdbuf .buf , "" )) {
568568 data -> no_disconnect_req = 1 ;
569569 if (debug )
@@ -739,22 +739,16 @@ static int push_update_ref_status(struct strbuf *buf,
739739 return !(status == REF_STATUS_OK );
740740}
741741
742- static int push_update_refs_status (struct helper_data * data ,
742+ static void push_update_refs_status (struct helper_data * data ,
743743 struct ref * remote_refs ,
744744 int flags )
745745{
746746 struct strbuf buf = STRBUF_INIT ;
747747 struct ref * ref = remote_refs ;
748- int ret = 0 ;
749-
750748 for (;;) {
751749 char * private ;
752750
753- if (recvline (data , & buf )) {
754- ret = 1 ;
755- break ;
756- }
757-
751+ recvline (data , & buf );
758752 if (!buf .len )
759753 break ;
760754
@@ -772,7 +766,6 @@ static int push_update_refs_status(struct helper_data *data,
772766 free (private );
773767 }
774768 strbuf_release (& buf );
775- return ret ;
776769}
777770
778771static int push_refs_with_push (struct transport * transport ,
@@ -853,7 +846,8 @@ static int push_refs_with_push(struct transport *transport,
853846 sendline (data , & buf );
854847 strbuf_release (& buf );
855848
856- return push_update_refs_status (data , remote_refs , flags );
849+ push_update_refs_status (data , remote_refs , flags );
850+ return 0 ;
857851}
858852
859853static int push_refs_with_export (struct transport * transport ,
@@ -911,15 +905,7 @@ static int push_refs_with_export(struct transport *transport,
911905
912906 if (finish_command (& exporter ))
913907 die ("Error while running fast-export" );
914- if (push_update_refs_status (data , remote_refs , flags ))
915- return 1 ;
916-
917- if (data -> export_marks ) {
918- strbuf_addf (& buf , "%s.tmp" , data -> export_marks );
919- rename (buf .buf , data -> export_marks );
920- strbuf_release (& buf );
921- }
922-
908+ push_update_refs_status (data , remote_refs , flags );
923909 return 0 ;
924910}
925911
@@ -988,8 +974,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
988974
989975 while (1 ) {
990976 char * eov , * eon ;
991- if (recvline (data , & buf ))
992- exit (128 );
977+ recvline (data , & buf );
993978
994979 if (!* buf .buf )
995980 break ;
0 commit comments