@@ -58,7 +58,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
58
58
if (strbuf_getline (buffer , helper , '\n' ) == EOF ) {
59
59
if (debug )
60
60
fprintf (stderr , "Debug: Remote helper quit.\n" );
61
- return 1 ;
61
+ exit ( 128 ) ;
62
62
}
63
63
64
64
if (debug )
@@ -71,6 +71,12 @@ static int recvline(struct helper_data *helper, struct strbuf *buffer)
71
71
return recvline_fh (helper -> out , buffer , helper -> name );
72
72
}
73
73
74
+ static void xchgline (struct helper_data * helper , struct strbuf * buffer )
75
+ {
76
+ sendline (helper , buffer );
77
+ recvline (helper , buffer );
78
+ }
79
+
74
80
static void write_constant (int fd , const char * str )
75
81
{
76
82
if (debug )
@@ -157,8 +163,7 @@ static struct child_process *get_helper(struct transport *transport)
157
163
while (1 ) {
158
164
const char * capname ;
159
165
int mandatory = 0 ;
160
- if (recvline (data , & buf ))
161
- exit (128 );
166
+ recvline (data , & buf );
162
167
163
168
if (!* buf .buf )
164
169
break ;
@@ -195,9 +200,15 @@ static struct child_process *get_helper(struct transport *transport)
195
200
} else if (!strcmp (capname , "signed-tags" )) {
196
201
data -> signed_tags = 1 ;
197
202
} 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 );
199
207
} 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 );
201
212
} else if (starts_with (capname , "no-private-update" )) {
202
213
data -> no_private_update = 1 ;
203
214
} else if (mandatory ) {
@@ -296,9 +307,7 @@ static int set_helper_option(struct transport *transport,
296
307
quote_c_style (value , & buf , NULL , 0 );
297
308
strbuf_addch (& buf , '\n' );
298
309
299
- sendline (data , & buf );
300
- if (recvline (data , & buf ))
301
- exit (128 );
310
+ xchgline (data , & buf );
302
311
303
312
if (!strcmp (buf .buf , "ok" ))
304
313
ret = 0 ;
@@ -370,8 +379,7 @@ static int fetch_with_fetch(struct transport *transport,
370
379
sendline (data , & buf );
371
380
372
381
while (1 ) {
373
- if (recvline (data , & buf ))
374
- exit (128 );
382
+ recvline (data , & buf );
375
383
376
384
if (starts_with (buf .buf , "lock " )) {
377
385
const char * name = buf .buf + 5 ;
@@ -422,8 +430,6 @@ static int get_exporter(struct transport *transport,
422
430
struct helper_data * data = transport -> data ;
423
431
struct child_process * helper = get_helper (transport );
424
432
int argc = 0 , i ;
425
- struct strbuf tmp = STRBUF_INIT ;
426
-
427
433
memset (fastexport , 0 , sizeof (* fastexport ));
428
434
429
435
/* we need to duplicate helper->in because we want to use it after
@@ -434,14 +440,10 @@ static int get_exporter(struct transport *transport,
434
440
fastexport -> argv [argc ++ ] = "--use-done-feature" ;
435
441
fastexport -> argv [argc ++ ] = data -> signed_tags ?
436
442
"--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 ;
445
447
446
448
for (i = 0 ; i < revlist_args -> nr ; i ++ )
447
449
fastexport -> argv [argc ++ ] = revlist_args -> items [i ].string ;
@@ -561,9 +563,7 @@ static int process_connect_service(struct transport *transport,
561
563
goto exit ;
562
564
563
565
sendline (data , & cmdbuf );
564
- if (recvline_fh (input , & cmdbuf , name ))
565
- exit (128 );
566
-
566
+ recvline_fh (input , & cmdbuf , name );
567
567
if (!strcmp (cmdbuf .buf , "" )) {
568
568
data -> no_disconnect_req = 1 ;
569
569
if (debug )
@@ -739,22 +739,16 @@ static int push_update_ref_status(struct strbuf *buf,
739
739
return !(status == REF_STATUS_OK );
740
740
}
741
741
742
- static int push_update_refs_status (struct helper_data * data ,
742
+ static void push_update_refs_status (struct helper_data * data ,
743
743
struct ref * remote_refs ,
744
744
int flags )
745
745
{
746
746
struct strbuf buf = STRBUF_INIT ;
747
747
struct ref * ref = remote_refs ;
748
- int ret = 0 ;
749
-
750
748
for (;;) {
751
749
char * private ;
752
750
753
- if (recvline (data , & buf )) {
754
- ret = 1 ;
755
- break ;
756
- }
757
-
751
+ recvline (data , & buf );
758
752
if (!buf .len )
759
753
break ;
760
754
@@ -772,7 +766,6 @@ static int push_update_refs_status(struct helper_data *data,
772
766
free (private );
773
767
}
774
768
strbuf_release (& buf );
775
- return ret ;
776
769
}
777
770
778
771
static int push_refs_with_push (struct transport * transport ,
@@ -853,7 +846,8 @@ static int push_refs_with_push(struct transport *transport,
853
846
sendline (data , & buf );
854
847
strbuf_release (& buf );
855
848
856
- return push_update_refs_status (data , remote_refs , flags );
849
+ push_update_refs_status (data , remote_refs , flags );
850
+ return 0 ;
857
851
}
858
852
859
853
static int push_refs_with_export (struct transport * transport ,
@@ -911,15 +905,7 @@ static int push_refs_with_export(struct transport *transport,
911
905
912
906
if (finish_command (& exporter ))
913
907
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 );
923
909
return 0 ;
924
910
}
925
911
@@ -988,8 +974,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
988
974
989
975
while (1 ) {
990
976
char * eov , * eon ;
991
- if (recvline (data , & buf ))
992
- exit (128 );
977
+ recvline (data , & buf );
993
978
994
979
if (!* buf .buf )
995
980
break ;
0 commit comments