@@ -863,7 +863,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
863
863
const struct ref * refs , * remote_head ;
864
864
struct ref * remote_head_points_at = NULL ;
865
865
const struct ref * our_head_points_at ;
866
- struct ref * mapped_refs ;
866
+ struct ref * mapped_refs = NULL ;
867
867
const struct ref * ref ;
868
868
struct strbuf key = STRBUF_INIT ;
869
869
struct strbuf branch_top = STRBUF_INIT , reflog_msg = STRBUF_INIT ;
@@ -1185,7 +1185,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1185
1185
1186
1186
refs = transport_get_remote_refs (transport , & transport_ls_refs_options );
1187
1187
1188
- if (refs ) {
1188
+ if (refs )
1189
+ mapped_refs = wanted_peer_refs (refs , & remote -> fetch );
1190
+
1191
+ if (mapped_refs ) {
1189
1192
int hash_algo = hash_algo_by_ptr (transport_get_hash_algo (transport ));
1190
1193
1191
1194
/*
@@ -1194,8 +1197,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1194
1197
*/
1195
1198
initialize_repository_version (hash_algo , 1 );
1196
1199
repo_set_hash_algo (the_repository , hash_algo );
1197
-
1198
- mapped_refs = wanted_peer_refs (refs , & remote -> fetch );
1199
1200
/*
1200
1201
* transport_get_remote_refs() may return refs with null sha-1
1201
1202
* in mapped_refs (see struct transport->get_refs_list
@@ -1241,7 +1242,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1241
1242
option_branch , remote_name );
1242
1243
1243
1244
warning (_ ("You appear to have cloned an empty repository." ));
1244
- mapped_refs = NULL ;
1245
1245
our_head_points_at = NULL ;
1246
1246
remote_head_points_at = NULL ;
1247
1247
remote_head = NULL ;
@@ -1272,7 +1272,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1272
1272
1273
1273
if (is_local )
1274
1274
clone_local (path , git_dir );
1275
- else if (refs && complete_refs_before_fetch ) {
1275
+ else if (mapped_refs && complete_refs_before_fetch ) {
1276
1276
if (transport_fetch_refs (transport , mapped_refs ))
1277
1277
die (_ ("remote transport reported error" ));
1278
1278
}
0 commit comments