@@ -545,14 +545,13 @@ static int fetch_with_import(struct transport *transport,
545
545
return 0 ;
546
546
}
547
547
548
- static int process_connect_service (struct transport * transport ,
549
- const char * name , const char * exec )
548
+ static int run_connect (struct transport * transport , struct strbuf * cmdbuf )
550
549
{
551
550
struct helper_data * data = transport -> data ;
552
- struct strbuf cmdbuf = STRBUF_INIT ;
553
- struct child_process * helper ;
554
- int r , duped , ret = 0 ;
551
+ int ret = 0 ;
552
+ int duped ;
555
553
FILE * input ;
554
+ struct child_process * helper ;
556
555
557
556
helper = get_helper (transport );
558
557
@@ -568,44 +567,54 @@ static int process_connect_service(struct transport *transport,
568
567
input = xfdopen (duped , "r" );
569
568
setvbuf (input , NULL , _IONBF , 0 );
570
569
570
+ sendline (data , cmdbuf );
571
+ if (recvline_fh (input , cmdbuf ))
572
+ exit (128 );
573
+
574
+ if (!strcmp (cmdbuf -> buf , "" )) {
575
+ data -> no_disconnect_req = 1 ;
576
+ if (debug )
577
+ fprintf (stderr , "Debug: Smart transport connection "
578
+ "ready.\n" );
579
+ ret = 1 ;
580
+ } else if (!strcmp (cmdbuf -> buf , "fallback" )) {
581
+ if (debug )
582
+ fprintf (stderr , "Debug: Falling back to dumb "
583
+ "transport.\n" );
584
+ } else {
585
+ die ("Unknown response to connect: %s" ,
586
+ cmdbuf -> buf );
587
+ }
588
+
589
+ fclose (input );
590
+ return ret ;
591
+ }
592
+
593
+ static int process_connect_service (struct transport * transport ,
594
+ const char * name , const char * exec )
595
+ {
596
+ struct helper_data * data = transport -> data ;
597
+ struct strbuf cmdbuf = STRBUF_INIT ;
598
+ int ret = 0 ;
599
+
571
600
/*
572
601
* Handle --upload-pack and friends. This is fire and forget...
573
602
* just warn if it fails.
574
603
*/
575
604
if (strcmp (name , exec )) {
576
- r = set_helper_option (transport , "servpath" , exec );
605
+ int r = set_helper_option (transport , "servpath" , exec );
577
606
if (r > 0 )
578
607
warning ("Setting remote service path not supported by protocol." );
579
608
else if (r < 0 )
580
609
warning ("Invalid remote service path." );
581
610
}
582
611
583
- if (data -> connect )
612
+ if (data -> connect ) {
584
613
strbuf_addf (& cmdbuf , "connect %s\n" , name );
585
- else
586
- goto exit ;
587
-
588
- sendline (data , & cmdbuf );
589
- if (recvline_fh (input , & cmdbuf ))
590
- exit (128 );
591
-
592
- if (!strcmp (cmdbuf .buf , "" )) {
593
- data -> no_disconnect_req = 1 ;
594
- if (debug )
595
- fprintf (stderr , "Debug: Smart transport connection "
596
- "ready.\n" );
597
- ret = 1 ;
598
- } else if (!strcmp (cmdbuf .buf , "fallback" )) {
599
- if (debug )
600
- fprintf (stderr , "Debug: Falling back to dumb "
601
- "transport.\n" );
602
- } else
603
- die ("Unknown response to connect: %s" ,
604
- cmdbuf .buf );
614
+ ret = run_connect (transport , & cmdbuf );
615
+ }
605
616
606
- exit :
607
617
strbuf_release (& cmdbuf );
608
- fclose (input );
609
618
return ret ;
610
619
}
611
620
0 commit comments