summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c122
1 files changed, 0 insertions, 122 deletions
diff --git a/remote.c b/remote.c
index b510809a56..4c5940482f 100644
--- a/remote.c
+++ b/remote.c
@@ -925,128 +925,6 @@ struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
return ref_map;
}
-static int refspec_find_negative_match(struct refspec *rs, struct refspec_item *query)
-{
- int i, matched_negative = 0;
- int find_src = !query->src;
- struct string_list reversed = STRING_LIST_INIT_DUP;
- const char *needle = find_src ? query->dst : query->src;
-
- /*
- * Check whether the queried ref matches any negative refpsec. If so,
- * then we should ultimately treat this as not matching the query at
- * all.
- *
- * Note that negative refspecs always match the source, but the query
- * item uses the destination. To handle this, we apply pattern
- * refspecs in reverse to figure out if the query source matches any
- * of the negative refspecs.
- *
- * The first loop finds and expands all positive refspecs
- * matched by the queried ref.
- *
- * The second loop checks if any of the results of the first loop
- * match any negative refspec.
- */
- for (i = 0; i < rs->nr; i++) {
- struct refspec_item *refspec = &rs->items[i];
- char *expn_name;
-
- if (refspec->negative)
- continue;
-
- /* Note the reversal of src and dst */
- if (refspec->pattern) {
- const char *key = refspec->dst ? refspec->dst : refspec->src;
- const char *value = refspec->src;
-
- if (match_name_with_pattern(key, needle, value, &expn_name))
- string_list_append_nodup(&reversed, expn_name);
- } else if (refspec->matching) {
- /* For the special matching refspec, any query should match */
- string_list_append(&reversed, needle);
- } else if (!refspec->src) {
- BUG("refspec->src should not be null here");
- } else if (!strcmp(needle, refspec->src)) {
- string_list_append(&reversed, refspec->src);
- }
- }
-
- for (i = 0; !matched_negative && i < reversed.nr; i++) {
- if (refname_matches_negative_refspec_item(reversed.items[i].string, rs))
- matched_negative = 1;
- }
-
- string_list_clear(&reversed, 0);
-
- return matched_negative;
-}
-
-static void refspec_find_all_matches(struct refspec *rs,
- struct refspec_item *query,
- struct string_list *results)
-{
- int i;
- int find_src = !query->src;
-
- if (find_src && !query->dst)
- BUG("refspec_find_all_matches: need either src or dst");
-
- if (refspec_find_negative_match(rs, query))
- return;
-
- for (i = 0; i < rs->nr; i++) {
- struct refspec_item *refspec = &rs->items[i];
- const char *key = find_src ? refspec->dst : refspec->src;
- const char *value = find_src ? refspec->src : refspec->dst;
- const char *needle = find_src ? query->dst : query->src;
- char **result = find_src ? &query->src : &query->dst;
-
- if (!refspec->dst || refspec->negative)
- continue;
- if (refspec->pattern) {
- if (match_name_with_pattern(key, needle, value, result))
- string_list_append_nodup(results, *result);
- } else if (!strcmp(needle, key)) {
- string_list_append(results, value);
- }
- }
-}
-
-int refspec_find_match(struct refspec *rs, struct refspec_item *query)
-{
- int i;
- int find_src = !query->src;
- const char *needle = find_src ? query->dst : query->src;
- char **result = find_src ? &query->src : &query->dst;
-
- if (find_src && !query->dst)
- BUG("refspec_find_match: need either src or dst");
-
- if (refspec_find_negative_match(rs, query))
- return -1;
-
- for (i = 0; i < rs->nr; i++) {
- struct refspec_item *refspec = &rs->items[i];
- const char *key = find_src ? refspec->dst : refspec->src;
- const char *value = find_src ? refspec->src : refspec->dst;
-
- if (!refspec->dst || refspec->negative)
- continue;
- if (refspec->pattern) {
- if (match_name_with_pattern(key, needle, value, result)) {
- query->force = refspec->force;
- return 0;
- }
- } else if (!strcmp(needle, key)) {
- *result = xstrdup(value);
- query->force = refspec->force;
- return 0;
- }
- }
- return -1;
-}
-
char *apply_refspecs(struct refspec *rs, const char *name)
{
struct refspec_item query;