aboutsummaryrefslogtreecommitdiffstats
path: root/refspec.c
diff options
context:
space:
mode:
Diffstat (limited to 'refspec.c')
-rw-r--r--refspec.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/refspec.c b/refspec.c
index cab0b0d127..0dbbd1e799 100644
--- a/refspec.c
+++ b/refspec.c
@@ -9,6 +9,7 @@
#include "strvec.h"
#include "refs.h"
#include "refspec.h"
+#include "remote.h"
#include "strbuf.h"
/*
@@ -447,3 +448,34 @@ int refspec_find_match(struct refspec *rs, struct refspec_item *query)
}
return -1;
}
+
+struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
+{
+ struct ref **tail;
+
+ for (tail = &ref_map; *tail; ) {
+ struct ref *ref = *tail;
+
+ if (refname_matches_negative_refspec_item(ref->name, rs)) {
+ *tail = ref->next;
+ free(ref->peer_ref);
+ free(ref);
+ } else
+ tail = &ref->next;
+ }
+
+ return ref_map;
+}
+
+char *apply_refspecs(struct refspec *rs, const char *name)
+{
+ struct refspec_item query;
+
+ memset(&query, 0, sizeof(struct refspec_item));
+ query.src = (char *)name;
+
+ if (refspec_find_match(rs, &query))
+ return NULL;
+
+ return query.dst;
+}