diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-09-01 13:40:17 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-09-01 13:40:17 -0700 |
| commit | 68ef0425d99cafb08f4c33eaa558505068fe2143 (patch) | |
| tree | f9a0229380b5770646c029ce7fa1baad0dcf337e /remote-curl.c | |
| parent | d42b38dfb5edf1a7fddd9542d722f91038407819 (diff) | |
| parent | 65da93891680edc0d1471d436d92d4da7d0b4465 (diff) | |
Merge branch 'ds/bundle-uri-clone'
Implement "git clone --bundle-uri".
* ds/bundle-uri-clone:
clone: warn on failure to repo_init()
clone: --bundle-uri cannot be combined with --depth
bundle-uri: add support for http(s):// and file://
clone: add --bundle-uri option
bundle-uri: create basic file-copy logic
remote-curl: add 'get' capability
Diffstat (limited to 'remote-curl.c')
| -rw-r--r-- | remote-curl.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c index b8758757ec..72dfb8fb86 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1286,6 +1286,29 @@ static void parse_fetch(struct strbuf *buf) strbuf_reset(buf); } +static void parse_get(const char *arg) +{ + struct strbuf url = STRBUF_INIT; + struct strbuf path = STRBUF_INIT; + const char *space; + + space = strchr(arg, ' '); + + if (!space) + die(_("protocol error: expected '<url> <path>', missing space")); + + strbuf_add(&url, arg, space - arg); + strbuf_addstr(&path, space + 1); + + if (http_get_file(url.buf, path.buf, NULL)) + die(_("failed to download file at URL '%s'"), url.buf); + + strbuf_release(&url); + strbuf_release(&path); + printf("\n"); + fflush(stdout); +} + static int push_dav(int nr_spec, const char **specs) { struct child_process child = CHILD_PROCESS_INIT; @@ -1564,9 +1587,14 @@ int cmd_main(int argc, const char **argv) printf("unsupported\n"); fflush(stdout); + } else if (skip_prefix(buf.buf, "get ", &arg)) { + parse_get(arg); + fflush(stdout); + } else if (!strcmp(buf.buf, "capabilities")) { printf("stateless-connect\n"); printf("fetch\n"); + printf("get\n"); printf("option\n"); printf("push\n"); printf("check-connectivity\n"); |
