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.