@@ -232,9 +232,6 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
232232{
233233 char * ref_git ;
234234 struct strbuf alternate = STRBUF_INIT ;
235- struct remote * remote ;
236- struct transport * transport ;
237- const struct ref * extra ;
238235
239236 /* Beware: real_path() and mkpath() return static buffer */
240237 ref_git = xstrdup (real_path (item -> string ));
@@ -249,14 +246,6 @@ static int add_one_reference(struct string_list_item *item, void *cb_data)
249246 strbuf_addf (& alternate , "%s/objects" , ref_git );
250247 add_to_alternates_file (alternate .buf );
251248 strbuf_release (& alternate );
252-
253- remote = remote_get (ref_git );
254- transport = transport_get (remote , ref_git );
255- for (extra = transport_get_remote_refs (transport ); extra ;
256- extra = extra -> next )
257- add_extra_ref (extra -> name , extra -> old_sha1 , 0 );
258-
259- transport_disconnect (transport );
260249 free (ref_git );
261250 return 0 ;
262251}
@@ -500,7 +489,6 @@ static void update_remote_refs(const struct ref *refs,
500489 const char * msg )
501490{
502491 if (refs ) {
503- clear_extra_refs ();
504492 write_remote_refs (mapped_refs );
505493 if (option_single_branch )
506494 write_followtags (refs , msg );
@@ -813,28 +801,28 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
813801 }
814802
815803 refs = transport_get_remote_refs (transport );
816- mapped_refs = refs ? wanted_peer_refs (refs , refspec ) : NULL ;
817804
818- /*
819- * transport_get_remote_refs() may return refs with null sha-1
820- * in mapped_refs (see struct transport->get_refs_list
821- * comment). In that case we need fetch it early because
822- * remote_head code below relies on it.
823- *
824- * for normal clones, transport_get_remote_refs() should
825- * return reliable ref set, we can delay cloning until after
826- * remote HEAD check.
827- */
828- for (ref = refs ; ref ; ref = ref -> next )
829- if (is_null_sha1 (ref -> old_sha1 )) {
830- complete_refs_before_fetch = 0 ;
831- break ;
832- }
805+ if (refs ) {
806+ mapped_refs = wanted_peer_refs (refs , refspec );
807+ /*
808+ * transport_get_remote_refs() may return refs with null sha-1
809+ * in mapped_refs (see struct transport->get_refs_list
810+ * comment). In that case we need fetch it early because
811+ * remote_head code below relies on it.
812+ *
813+ * for normal clones, transport_get_remote_refs() should
814+ * return reliable ref set, we can delay cloning until after
815+ * remote HEAD check.
816+ */
817+ for (ref = refs ; ref ; ref = ref -> next )
818+ if (is_null_sha1 (ref -> old_sha1 )) {
819+ complete_refs_before_fetch = 0 ;
820+ break ;
821+ }
833822
834- if (!is_local && !complete_refs_before_fetch && refs )
835- transport_fetch_refs (transport , mapped_refs );
823+ if (!is_local && !complete_refs_before_fetch )
824+ transport_fetch_refs (transport , mapped_refs );
836825
837- if (refs ) {
838826 remote_head = find_ref_by_name (refs , "HEAD" );
839827 remote_head_points_at =
840828 guess_remote_head (remote_head , mapped_refs , 0 );
@@ -852,6 +840,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
852840 }
853841 else {
854842 warning (_ ("You appear to have cloned an empty repository." ));
843+ mapped_refs = NULL ;
855844 our_head_points_at = NULL ;
856845 remote_head_points_at = NULL ;
857846 remote_head = NULL ;
0 commit comments