Re: [RFC v2 1/1] refspec: add support for negative refspecs
Hi Jake,
On Fri, 21 Aug 2020, Jacob Keller wrote:
Show 31 quoted lines
> static void query_refspecs_multiple(struct refspec *rs,
> struct refspec_item *query,
> struct string_list *results)
> {
> - int i;
> + 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;
> + char **result = find_src ? &query->src : &query->dst;
>
> if (find_src && !query->dst)
> BUG("query_refspecs_multiple: need either src or dst");
>
> + /*
> + * If a ref matches any of the negative refspecs, then we should treat
> + * it as not matching this query. Note that negative refspecs apply to
> + * the source but we're checking only the destination. Reverse and
> + * capture any pattern refspecs in order to see if the source would
> + * have matched a 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->src;This breaks at least with Visual C. I need this to unbreak the build:
-- snipsnap --
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@gmx.de>
---
remote.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index 940622e0ba88..8e081863c06d 100644
--- a/remote.c
+++ b/remote.c
@@ -731,7 +731,7 @@ static void query_refspecs_multiple(struct refspec *rs,
/* 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))
@@ -795,7 +795,7 @@ int query_refspecs(struct refspec *rs, struct refspec_item *query)
/* 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