Hi Jake, On Fri, 25 Sep 2020, Jacob Keller wrote: > diff --git a/remote.c b/remote.c > index eafc14cbe759..26a127142344 100644 > --- a/remote.c > +++ b/remote.c > @@ -682,6 +682,91 @@ static int match_name_with_pattern(const char *key, const char *name, > return ret; > } > > +static int refspec_match(const struct refspec_item *refspec, > + const char *name) > +{ > + if (refspec->pattern) > + return match_name_with_pattern(refspec->src, name, NULL, NULL); > + > + return !strcmp(refspec->src, name); > +} > + > +static int omit_name_by_refspec(const char *name, struct refspec *rs) > +{ > + int i; > + > + for (i = 0; i < rs->nr; i++) { > + if (rs->items[i].negative && refspec_match(&rs->items[i], name)) > + return 1; > + } > + return 0; > +} > + > +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 (omit_name_by_refspec(ref->name, rs)) { > + *tail = ref->next; > + free(ref->peer_ref); > + free(ref); > + } else > + tail = &ref->next; > + } > + > + return ref_map; > +} > + > +static int query_matches_negative_refspec(struct refspec *rs, struct refspec_item *query) > +{ > + int i, matched_negative = 0; > + int find_src = !query->src; > + struct string_list reversed = STRING_LIST_INIT_NODUP; > + 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. > + */ > + 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->src; Would you mind fixing this? This keeps getting reverted... -- snipsnap -- >From 4aea2a58a9f6bb1cbbc7a03db63a1465f9a801da Mon Sep 17 00:00:00 2001 From: Johannes Schindelin <johannes.schindelin@xxxxxx> Date: Sun, 23 Aug 2020 22:27:17 +0200 Subject: [PATCH] fixup??? refspec: add support for negative refspecs The `?:` operator is not supported e.g. by Visual C. Let's not use it. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- remote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.c b/remote.c index f7d20c059b3e..1659535c1a8d 100644 --- a/remote.c +++ b/remote.c @@ -724,7 +724,7 @@ static int query_matches_negative_refspec(struct refspec *rs, struct refspec_ite /* Note the reversal of src and dst */ if (refspec->pattern) { - const char *key = refspec->dst ?: refspec->src; + const char *key = refspec->dst ? refspec->dst : refspec->src; const char *value = refspec->src; if (match_name_with_pattern(key, needle, value, &expn_name)) -- 2.28.0.windows.1.52.gbcabfe850c5e