File tree Expand file tree Collapse file tree 4 files changed +44
-42
lines changed Expand file tree Collapse file tree 4 files changed +44
-42
lines changed Original file line number Diff line number Diff line change 99#include "strvec.h"
1010#include "refs.h"
1111#include "refspec.h"
12+ #include "remote.h"
1213#include "strbuf.h"
1314
1415/*
@@ -447,3 +448,34 @@ int refspec_find_match(struct refspec *rs, struct refspec_item *query)
447448 }
448449 return -1 ;
449450}
451+
452+ struct ref * apply_negative_refspecs (struct ref * ref_map , struct refspec * rs )
453+ {
454+ struct ref * * tail ;
455+
456+ for (tail = & ref_map ; * tail ; ) {
457+ struct ref * ref = * tail ;
458+
459+ if (refname_matches_negative_refspec_item (ref -> name , rs )) {
460+ * tail = ref -> next ;
461+ free (ref -> peer_ref );
462+ free (ref );
463+ } else
464+ tail = & ref -> next ;
465+ }
466+
467+ return ref_map ;
468+ }
469+
470+ char * apply_refspecs (struct refspec * rs , const char * name )
471+ {
472+ struct refspec_item query ;
473+
474+ memset (& query , 0 , sizeof (struct refspec_item ));
475+ query .src = (char * )name ;
476+
477+ if (refspec_find_match (rs , & query ))
478+ return NULL ;
479+
480+ return query .dst ;
481+ }
Original file line number Diff line number Diff line change @@ -96,4 +96,16 @@ void refspec_find_all_matches(struct refspec *rs,
9696 struct refspec_item * query ,
9797 struct string_list * results );
9898
99+ /*
100+ * Remove all entries in the input list which match any negative refspec in
101+ * the refspec list.
102+ */
103+ struct ref * apply_negative_refspecs (struct ref * ref_map , struct refspec * rs );
104+
105+ /*
106+ * Search for a refspec that matches the given name and return the
107+ * corresponding destination (dst) if a match is found, NULL otherwise.
108+ */
109+ char * apply_refspecs (struct refspec * rs , const char * name );
110+
99111#endif /* REFSPEC_H */
Original file line number Diff line number Diff line change @@ -907,37 +907,6 @@ void ref_push_report_free(struct ref_push_report *report)
907907 }
908908}
909909
910- struct ref * apply_negative_refspecs (struct ref * ref_map , struct refspec * rs )
911- {
912- struct ref * * tail ;
913-
914- for (tail = & ref_map ; * tail ; ) {
915- struct ref * ref = * tail ;
916-
917- if (refname_matches_negative_refspec_item (ref -> name , rs )) {
918- * tail = ref -> next ;
919- free (ref -> peer_ref );
920- free (ref );
921- } else
922- tail = & ref -> next ;
923- }
924-
925- return ref_map ;
926- }
927-
928- char * apply_refspecs (struct refspec * rs , const char * name )
929- {
930- struct refspec_item query ;
931-
932- memset (& query , 0 , sizeof (struct refspec_item ));
933- query .src = (char * )name ;
934-
935- if (refspec_find_match (rs , & query ))
936- return NULL ;
937-
938- return query .dst ;
939- }
940-
941910int remote_find_tracking (struct remote * remote , struct refspec_item * refspec )
942911{
943912 return refspec_find_match (& remote -> fetch , refspec );
Original file line number Diff line number Diff line change @@ -261,17 +261,6 @@ int resolve_remote_symref(struct ref *ref, struct ref *list);
261261 */
262262struct ref * ref_remove_duplicates (struct ref * ref_map );
263263
264- int refname_matches_negative_refspec_item (const char * refname , struct refspec * rs );
265-
266- /*
267- * Remove all entries in the input list which match any negative refspec in
268- * the refspec list.
269- */
270- struct ref * apply_negative_refspecs (struct ref * ref_map , struct refspec * rs );
271-
272- int refspec_find_match (struct refspec * rs , struct refspec_item * query );
273- char * apply_refspecs (struct refspec * rs , const char * name );
274-
275264int check_push_refs (struct ref * src , struct refspec * rs );
276265int match_push_refs (struct ref * src , struct ref * * dst ,
277266 struct refspec * rs , int flags );
You can’t perform that action at this time.
0 commit comments