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

Re: [PATCH] remote-curl: make --force-with-lease work with non-ASCII ref names

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2020, 00:02 UTC
Message-ID
<xmqqlfjd91ll.fsf@gitster.c.googlers.com>
In-Reply-To
<20200720224327.1631947-1-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 16 quoted lines
> diff --git a/remote-curl.c b/remote-curl.c
> index 5cbc6e5002..ccf0c27daf 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -121,7 +121,13 @@ static int set_option(const char *name, const char *value)
>  	}
>  	else if (!strcmp(name, "cas")) {
>  		struct strbuf val = STRBUF_INIT;
> -		strbuf_addf(&val, "--" CAS_OPT_NAME "=%s", value);
> +		strbuf_addstr(&val, "--" CAS_OPT_NAME "=");
> +		if (*value == '"') {
> +			if (unquote_c_style(&val, value, NULL))
> +				return -1;
> +		} else {
> +			strbuf_addstr(&val, value);
> +		}
I wonder if
		if (*value != '"')
			strbuf_addstr(&val, value);
		else if (unquote_c_style(&val, value, NULL))
			return -1; /* error */

is easier to read without having to use {braces}, but that's quite a minor point.

A clean-up opportunity I can see here is to declare that we have found a good value for CAS_OPT_NAME and inline the string and remove the C preprocessor macro, but that is obviously an unrelated change to this fix.

Thanks.
Previous: brian m. carlsonNext: brian m. carlson
Message 3 of 4 in “Cannot delete remote branch with non-ascii name and --force-with-lease”
  1. Frej BjonJul 15, 2020
  2. remote-curl: make --force-with-lease work with non-ASCII ref namesbrian m. carlson, Jul 20, 2020
  3. Junio C HamanoJul 21, 2020
  4. remote-curl: make --force-with-lease work with non-ASCII ref namesbrian m. carlson, Jul 21, 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.