@@ -1085,26 +1085,35 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
10851085 return NULL ;
10861086}
10871087
1088+ static struct ref * * tail_ref (struct ref * * head )
1089+ {
1090+ struct ref * * tail = head ;
1091+ while (* tail )
1092+ tail = & ((* tail )-> next );
1093+ return tail ;
1094+ }
1095+
10881096/*
10891097 * Note. This is used only by "push"; refspec matching rules for
10901098 * push and fetch are subtly different, so do not try to reuse it
10911099 * without thinking.
10921100 */
1093- int match_refs (struct ref * src , struct ref * dst , struct ref * * * dst_tail ,
1101+ int match_refs (struct ref * src , struct ref * * dst ,
10941102 int nr_refspec , const char * * refspec , int flags )
10951103{
10961104 struct refspec * rs ;
10971105 int send_all = flags & MATCH_REFS_ALL ;
10981106 int send_mirror = flags & MATCH_REFS_MIRROR ;
10991107 int errs ;
11001108 static const char * default_refspec [] = { ":" , 0 };
1109+ struct ref * * dst_tail = tail_ref (dst );
11011110
11021111 if (!nr_refspec ) {
11031112 nr_refspec = 1 ;
11041113 refspec = default_refspec ;
11051114 }
11061115 rs = parse_push_refspec (nr_refspec , (const char * * ) refspec );
1107- errs = match_explicit_refs (src , dst , dst_tail , rs , nr_refspec );
1116+ errs = match_explicit_refs (src , * dst , & dst_tail , rs , nr_refspec );
11081117
11091118 /* pick the remainder */
11101119 for ( ; src ; src = src -> next ) {
@@ -1134,7 +1143,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
11341143 dst_side , & dst_name ))
11351144 die ("Didn't think it matches any more" );
11361145 }
1137- dst_peer = find_ref_by_name (dst , dst_name );
1146+ dst_peer = find_ref_by_name (* dst , dst_name );
11381147 if (dst_peer ) {
11391148 if (dst_peer -> peer_ref )
11401149 /* We're already sending something to this ref. */
@@ -1150,7 +1159,7 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
11501159 goto free_name ;
11511160
11521161 /* Create a new one and link it */
1153- dst_peer = make_linked_ref (dst_name , dst_tail );
1162+ dst_peer = make_linked_ref (dst_name , & dst_tail );
11541163 hashcpy (dst_peer -> new_sha1 , src -> new_sha1 );
11551164 }
11561165 dst_peer -> peer_ref = copy_ref (src );
0 commit comments