git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC v2 1/1] refspec: add support for negative refspecs

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 22, 2020, 13:29 UTC
Message-ID
<nycvar.QRO.7.76.6.2008221528170.56@tvgsbejvaqbjf.bet>
In-Reply-To
<20200821215247.758978-2-jacob.e.keller@intel.com>
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
Previous: Jacob KellerNext: Jacob Keller
Message 3 of 10 in “[RFC v2 0/1] implement support for negative refspecs”
  1. Jacob KellerAug 21, 2020
  2. 1/1 refspec: add support for negative refspecsJacob Keller, Aug 21, 2020
  3. Johannes SchindelinAug 22, 2020
  4. Jacob KellerAug 24, 2020
  5. Junio C HamanoAug 24, 2020
  6. Jacob KellerAug 24, 2020
  7. Junio C HamanoSep 17, 2020
  8. Junio C HamanoSep 18, 2020
  9. Jacob KellerSep 24, 2020
  10. Jacob KellerSep 24, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.