Re: [PATCH 2/6] remote-curl: add 'get' capability
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2022, 22:59 UTC
- Message-ID
- <xmqq35eudqc3.fsf@gitster.g>
- In-Reply-To
- <977f0af40fc5cf3f0a7f167e2d2a47099168f47f.1654545325.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 20 quoted lines
> +static void parse_get(struct strbuf *buf)
> +{
> + struct http_get_options opts = { 0 };
> + struct strbuf url = STRBUF_INIT;
> + struct strbuf path = STRBUF_INIT;
> + const char *p, *space;
> +
> + if (!skip_prefix(buf->buf, "get ", &p))
> + die(_("http transport does not support %s"), buf->buf);
> +
> + space = strchr(p, ' ');
> +
> + if (!space)
> + die(_("protocol error: expected '<url> <path>', missing space"));
> +
> + strbuf_add(&url, p, space - p);
> + strbuf_addstr(&path, space + 1);
> +
> + if (http_get_file(url.buf, path.buf, &opts))
> + die(_("failed to download file at URL '%s'"), url.buf);Micronit:
Do we plan to add some "interesting" options later to opts?
Otherwise, the third parameter to http_get_file() can safely be NULL, I think.
> + test_must_fail git remote-http $url $url <input 2>err &&
It has been a while since I worked with remote-http, but does this need two $url?