@@ -548,7 +548,7 @@ static struct ref *find_remote_branch(const struct ref *refs, const char *branch
548
548
}
549
549
550
550
static struct ref * wanted_peer_refs (const struct ref * refs ,
551
- struct refspec_item * refspec )
551
+ struct refspec * refspec )
552
552
{
553
553
struct ref * head = copy_ref (find_ref_by_name (refs , "HEAD" ));
554
554
struct ref * local_refs = head ;
@@ -569,13 +569,19 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
569
569
warning (_ ("Could not find remote branch %s to clone." ),
570
570
option_branch );
571
571
else {
572
- get_fetch_map (remote_head , refspec , & tail , 0 );
572
+ int i ;
573
+ for (i = 0 ; i < refspec -> nr ; i ++ )
574
+ get_fetch_map (remote_head , & refspec -> items [i ],
575
+ & tail , 0 );
573
576
574
577
/* if --branch=tag, pull the requested tag explicitly */
575
578
get_fetch_map (remote_head , tag_refspec , & tail , 0 );
576
579
}
577
- } else
578
- get_fetch_map (refs , refspec , & tail , 0 );
580
+ } else {
581
+ int i ;
582
+ for (i = 0 ; i < refspec -> nr ; i ++ )
583
+ get_fetch_map (refs , & refspec -> items [i ], & tail , 0 );
584
+ }
579
585
580
586
if (!option_mirror && !option_single_branch && !option_no_tags )
581
587
get_fetch_map (refs , tag_refspec , & tail , 0 );
@@ -890,15 +896,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
890
896
const struct ref * our_head_points_at ;
891
897
struct ref * mapped_refs ;
892
898
const struct ref * ref ;
893
- struct strbuf key = STRBUF_INIT , value = STRBUF_INIT ;
899
+ struct strbuf key = STRBUF_INIT ;
900
+ struct strbuf default_refspec = STRBUF_INIT ;
894
901
struct strbuf branch_top = STRBUF_INIT , reflog_msg = STRBUF_INIT ;
895
902
struct transport * transport = NULL ;
896
903
const char * src_ref_prefix = "refs/heads/" ;
897
904
struct remote * remote ;
898
905
int err = 0 , complete_refs_before_fetch = 1 ;
899
906
int submodule_progress ;
900
907
901
- struct refspec rs = REFSPEC_INIT_FETCH ;
902
908
struct argv_array ref_prefixes = ARGV_ARRAY_INIT ;
903
909
904
910
fetch_if_missing = 0 ;
@@ -1067,7 +1073,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1067
1073
strbuf_addf (& branch_top , "refs/remotes/%s/" , option_origin );
1068
1074
}
1069
1075
1070
- strbuf_addf (& value , "+%s*:%s*" , src_ref_prefix , branch_top .buf );
1071
1076
strbuf_addf (& key , "remote.%s.url" , option_origin );
1072
1077
git_config_set (key .buf , repo );
1073
1078
strbuf_reset (& key );
@@ -1081,11 +1086,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1081
1086
if (option_required_reference .nr || option_optional_reference .nr )
1082
1087
setup_reference ();
1083
1088
1084
- refspec_append ( & rs , value . buf );
1089
+ remote = remote_get ( option_origin );
1085
1090
1086
- strbuf_reset (& value );
1091
+ strbuf_addf (& default_refspec , "+%s*:%s*" , src_ref_prefix ,
1092
+ branch_top .buf );
1093
+ refspec_append (& remote -> fetch , default_refspec .buf );
1087
1094
1088
- remote = remote_get (option_origin );
1089
1095
transport = transport_get (remote , remote -> url [0 ]);
1090
1096
transport_set_verbosity (transport , option_verbosity , option_progress );
1091
1097
transport -> family = family ;
@@ -1140,7 +1146,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1140
1146
1141
1147
1142
1148
argv_array_push (& ref_prefixes , "HEAD" );
1143
- refspec_ref_prefixes (& rs , & ref_prefixes );
1149
+ refspec_ref_prefixes (& remote -> fetch , & ref_prefixes );
1144
1150
if (option_branch )
1145
1151
expand_ref_prefix (& ref_prefixes , option_branch );
1146
1152
if (!option_no_tags )
@@ -1149,7 +1155,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1149
1155
refs = transport_get_remote_refs (transport , & ref_prefixes );
1150
1156
1151
1157
if (refs ) {
1152
- mapped_refs = wanted_peer_refs (refs , & rs . items [ 0 ] );
1158
+ mapped_refs = wanted_peer_refs (refs , & remote -> fetch );
1153
1159
/*
1154
1160
* transport_get_remote_refs() may return refs with null sha-1
1155
1161
* in mapped_refs (see struct transport->get_refs_list
@@ -1240,10 +1246,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1240
1246
strbuf_release (& reflog_msg );
1241
1247
strbuf_release (& branch_top );
1242
1248
strbuf_release (& key );
1243
- strbuf_release (& value );
1249
+ strbuf_release (& default_refspec );
1244
1250
junk_mode = JUNK_LEAVE_ALL ;
1245
1251
1246
- refspec_clear (& rs );
1247
1252
argv_array_clear (& ref_prefixes );
1248
1253
return err ;
1249
1254
}
0 commit comments