@@ -1285,23 +1285,20 @@ int check_push_refs(struct ref *src, int nr_refspec, const char **refspec_names)
12851285 * dst (e.g. pushing to a new branch, done in match_explicit_refs).
12861286 */
12871287int match_push_refs (struct ref * src , struct ref * * dst ,
1288- int nr_refspec , const char * * refspec , int flags )
1288+ struct refspec * rs , int flags )
12891289{
1290- struct refspec rs = REFSPEC_INIT_PUSH ;
12911290 int send_all = flags & MATCH_REFS_ALL ;
12921291 int send_mirror = flags & MATCH_REFS_MIRROR ;
12931292 int send_prune = flags & MATCH_REFS_PRUNE ;
12941293 int errs ;
1295- static const char * default_refspec [] = { ":" , NULL };
12961294 struct ref * ref , * * dst_tail = tail_ref (dst );
12971295 struct string_list dst_ref_index = STRING_LIST_INIT_NODUP ;
12981296
1299- if (!nr_refspec ) {
1300- nr_refspec = 1 ;
1301- refspec = default_refspec ;
1302- }
1303- refspec_appendn (& rs , refspec , nr_refspec );
1304- errs = match_explicit_refs (src , * dst , & dst_tail , & rs );
1297+ /* If no refspec is provided, use the default ":" */
1298+ if (!rs -> nr )
1299+ refspec_append (rs , ":" );
1300+
1301+ errs = match_explicit_refs (src , * dst , & dst_tail , rs );
13051302
13061303 /* pick the remainder */
13071304 for (ref = src ; ref ; ref = ref -> next ) {
@@ -1310,7 +1307,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13101307 const struct refspec_item * pat = NULL ;
13111308 char * dst_name ;
13121309
1313- dst_name = get_ref_match (& rs , ref , send_mirror , FROM_SRC , & pat );
1310+ dst_name = get_ref_match (rs , ref , send_mirror , FROM_SRC , & pat );
13141311 if (!dst_name )
13151312 continue ;
13161313
@@ -1359,7 +1356,7 @@ int match_push_refs(struct ref *src, struct ref **dst,
13591356 /* We're already sending something to this ref. */
13601357 continue ;
13611358
1362- src_name = get_ref_match (& rs , ref , send_mirror , FROM_DST , NULL );
1359+ src_name = get_ref_match (rs , ref , send_mirror , FROM_DST , NULL );
13631360 if (src_name ) {
13641361 if (!src_ref_index .nr )
13651362 prepare_ref_index (& src_ref_index , src );
@@ -1372,8 +1369,6 @@ int match_push_refs(struct ref *src, struct ref **dst,
13721369 string_list_clear (& src_ref_index , 0 );
13731370 }
13741371
1375- refspec_clear (& rs );
1376-
13771372 if (errs )
13781373 return -1 ;
13791374 return 0 ;
0 commit comments