@@ -720,6 +720,31 @@ static int truncate_fetch_head(void)
720
720
return 0 ;
721
721
}
722
722
723
+ static void set_option (struct transport * transport , const char * name , const char * value )
724
+ {
725
+ int r = transport_set_option (transport , name , value );
726
+ if (r < 0 )
727
+ die (_ ("Option \"%s\" value \"%s\" is not valid for %s" ),
728
+ name , value , transport -> url );
729
+ if (r > 0 )
730
+ warning (_ ("Option \"%s\" is ignored for %s\n" ),
731
+ name , transport -> url );
732
+ }
733
+
734
+ struct transport * prepare_transport (struct remote * remote )
735
+ {
736
+ struct transport * transport ;
737
+ transport = transport_get (remote , NULL );
738
+ transport_set_verbosity (transport , verbosity , progress );
739
+ if (upload_pack )
740
+ set_option (transport , TRANS_OPT_UPLOADPACK , upload_pack );
741
+ if (keep )
742
+ set_option (transport , TRANS_OPT_KEEP , "yes" );
743
+ if (depth )
744
+ set_option (transport , TRANS_OPT_DEPTH , depth );
745
+ return transport ;
746
+ }
747
+
723
748
static int do_fetch (struct transport * transport ,
724
749
struct refspec * refs , int ref_count )
725
750
{
@@ -816,17 +841,6 @@ static int do_fetch(struct transport *transport,
816
841
return retcode ;
817
842
}
818
843
819
- static void set_option (const char * name , const char * value )
820
- {
821
- int r = transport_set_option (gtransport , name , value );
822
- if (r < 0 )
823
- die (_ ("Option \"%s\" value \"%s\" is not valid for %s" ),
824
- name , value , gtransport -> url );
825
- if (r > 0 )
826
- warning (_ ("Option \"%s\" is ignored for %s\n" ),
827
- name , gtransport -> url );
828
- }
829
-
830
844
static int get_one_remote_for_fetch (struct remote * remote , void * priv )
831
845
{
832
846
struct string_list * list = priv ;
@@ -949,15 +963,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
949
963
die (_ ("No remote repository specified. Please, specify either a URL or a\n"
950
964
"remote name from which new revisions should be fetched." ));
951
965
952
- gtransport = transport_get (remote , NULL );
953
- transport_set_verbosity (gtransport , verbosity , progress );
954
- if (upload_pack )
955
- set_option (TRANS_OPT_UPLOADPACK , upload_pack );
956
- if (keep )
957
- set_option (TRANS_OPT_KEEP , "yes" );
958
- if (depth )
959
- set_option (TRANS_OPT_DEPTH , depth );
960
-
966
+ gtransport = prepare_transport (remote );
961
967
if (argc > 0 ) {
962
968
int j = 0 ;
963
969
refs = xcalloc (argc + 1 , sizeof (const char * ));
0 commit comments