From patchwork Tue Aug 2 12:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12934604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1BBBC19F2C for ; Tue, 2 Aug 2022 12:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237073AbiHBM3w (ORCPT ); Tue, 2 Aug 2022 08:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236877AbiHBM3u (ORCPT ); Tue, 2 Aug 2022 08:29:50 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03155073D for ; Tue, 2 Aug 2022 05:29:48 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 8-20020a05600c024800b003a2fe343db1so6888702wmj.1 for ; Tue, 02 Aug 2022 05:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=acdCRj0MaKKG5SLy1KyeFYDmc9lgpHivA8g86H8W2Bc=; b=bv3Nvf+lxgHkJbMS9bG+m7PMHAQ9GT8iFTGBtSpqDVcolwEpQl23pcuvWMnxgu0NJF uMBTOS0YbHOq4cMBF9SNYZapSIPIdss4oFz4r6yDIgSH9+TBx65W/0iLIYrb9Qtrzk2S Z03nTJEzY6JCx/YiYNBBc8GDxKydaWkKiI0zIFILmxHelMpFg9fpU13GqocnTEiDRJFf +SKJZG87xkEuesDHJqenoNDI7xGF30yShxRf+m2UqDWS3j3B/B1hIvvQ/jhTiQf1+ZwF S3sTBHYBYu1ePu2tIAUstgsbJcN538hRjT1BnGwL1Jk6w9GTcD6pYImXbXnU9Qssg5jZ 7WXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=acdCRj0MaKKG5SLy1KyeFYDmc9lgpHivA8g86H8W2Bc=; b=QMEGLNteioLfHa79wtxwYP90wgr1UViGMbGrLBeC91CeE33GkyQE96NqMp7o6E/5er 4T8eIEPRy/JdHwzirtNHy+nGF/hewWezALh4EO168BujH9xaeUtz3YGdkTgtMAdBxtBu 84dJbWyVcShv75kN9sgElT0vQ66tgjASe2f/kMu3k8Xe1T0gmGCWr/pDOhUKdkH+T+BR Ds566FavvHGBhUJQzdplVk3EQfNXkgX7SR5FZ31oF5d2cD+JU6U75Zc5K54Sikw7lb3l /hNSxHIBdv+G+WUwGrafnKTAeTBPOjBc9SmEx3L4A+zHiRzSFl+OXZTk3XqNsqNBA2ht gLhA== X-Gm-Message-State: AJIora9wB8fGPZIwOggobsr3gX53XjE9uz9ohDxYV+Trapp6M0RL862Y cXUb4Eb9v9EzYw8aAtfTgK/EuuhMi/s= X-Google-Smtp-Source: AGRyM1sO8jXAq2v8C1eHafUzQCgCcKtdrvguiBfOBw/v21GZCmocdO8rp3J99LSoiXmtn9TO60hqDA== X-Received: by 2002:a05:600c:501e:b0:3a3:4a04:fdb5 with SMTP id n30-20020a05600c501e00b003a34a04fdb5mr14601863wmr.168.1659443387135; Tue, 02 Aug 2022 05:29:47 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p6-20020a1c5446000000b003a2f96935c0sm27351614wmi.9.2022.08.02.05.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 05:29:45 -0700 (PDT) Message-Id: <4df4a1d679a1003ccd3a4dd049bc05141831970c.1659443384.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 02 Aug 2022 12:29:40 +0000 Subject: [PATCH v2 1/5] remote-curl: add 'get' capability Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, dyroneteng@gmail.com, Johannes.Schindelin@gmx.de, szeder.dev@gmail.com, mjcheetham@outlook.com, steadmon@google.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee A future change will want a way to download a file over HTTP(S) using the simplest of download mechanisms. We do not want to assume that the server on the other side understands anything about the Git protocol but could be a simple static web server. Create the new 'get' capability for the remote helpers which advertises that the 'get' command is avalable. A caller can send a line containing 'get ' to download the file at into the file at . Reviewed-by: Josh Steadmon Signed-off-by: Derrick Stolee --- Documentation/gitremote-helpers.txt | 9 +++++++ remote-curl.c | 28 ++++++++++++++++++++++ t/t5557-http-get.sh | 37 +++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100755 t/t5557-http-get.sh diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt index 6f1e269ae43..ed8da428c98 100644 --- a/Documentation/gitremote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@ -168,6 +168,9 @@ Supported commands: 'list', 'import'. Can guarantee that when a clone is requested, the received pack is self contained and is connected. +'get':: + Can use the 'get' command to download a file from a given URI. + If a helper advertises 'connect', Git will use it if possible and fall back to another capability if the helper requests so when connecting (see the 'connect' command under COMMANDS). @@ -418,6 +421,12 @@ Supported if the helper has the "connect" capability. + Supported if the helper has the "stateless-connect" capability. +'get' :: + Downloads the file from the given `` to the given ``. If + `.temp` exists, then Git assumes that the `.temp` file is a + partial download from a previous attempt and will resume the + download from that position. + If a fatal error occurs, the program writes the error message to stderr and exits. The caller should expect that a suitable error message has been printed if the child closes the connection without diff --git a/remote-curl.c b/remote-curl.c index b8758757ece..72dfb8fb86a 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 ' ', 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"); diff --git a/t/t5557-http-get.sh b/t/t5557-http-get.sh new file mode 100755 index 00000000000..09fb0bd9a8a --- /dev/null +++ b/t/t5557-http-get.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +test_description='test downloading a file by URL' + +. ./test-lib.sh + +. "$TEST_DIRECTORY"/lib-httpd.sh +start_httpd + +test_expect_success 'get by URL: 404' ' + test_when_finished "rm -f file.temp" && + url="$HTTPD_URL/none.txt" && + cat >input <<-EOF && + capabilities + get $url file1 + EOF + + test_must_fail git remote-http $url err && + test_path_is_missing file1 && + grep "failed to download file at URL" err +' + +test_expect_success 'get by URL: 200' ' + echo data >"$HTTPD_DOCUMENT_ROOT_PATH/exists.txt" && + + url="$HTTPD_URL/exists.txt" && + cat >input <<-EOF && + capabilities + get $url file2 + + EOF + + git remote-http $url X-Patchwork-Id: 12934605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44107C00140 for ; Tue, 2 Aug 2022 12:29:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237088AbiHBM3z (ORCPT ); Tue, 2 Aug 2022 08:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237069AbiHBM3v (ORCPT ); Tue, 2 Aug 2022 08:29:51 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0734251409 for ; Tue, 2 Aug 2022 05:29:50 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id z12so7594931wrs.9 for ; Tue, 02 Aug 2022 05:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hjSXw2K7hcxJrsGK0XrsEAkQYSIrIWRaUdxf9463oJI=; b=dOZRV4Q/kERCyAst7pzoPEihmgOJgaidr3iZvsmT5jPpM6pvZ1aqX06LCtzTzYyAe9 v/RPPd2owpUd/3CMYgOwP2apMqmX485QRRODyyjathhHLKRN9Q6HQLAxW2qS+GW66Kd9 Pkd1wBGTk4TTdl34cEImvtqKgX3kXzrdboewjhDp9o21wvOVq+YtgUAbCBAmtGvVM/ot zw5sCma6DCl64y4fkhtl8usyeDy1f3wiiURYO1XMt2prn4hdncOzM+OfmVmsUj4uVuvP FLMfcQbPu/U40L0SiHjCdqKkTaPA+cfpHlc4BobqvkJvIUTuA8IDF86rW9PgjHPuQZg7 WctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hjSXw2K7hcxJrsGK0XrsEAkQYSIrIWRaUdxf9463oJI=; b=MITjEIIyw9cc7IyjMJwMajUyIxF1dEUvNyhT0PthsLmsJ3BJwHz+m4EMswdz+ize6E 8R//LGGWSkemB71/XlicMDiM4MtJJCww13lHOmtalXnS9nnEk7w0UWWvWecTpXuh8bKU yjtA7eAqi65yH8DXTn8Att1iAH/7Qc15fvQ9edyS1T4/abC0vSnL/0hm8WrvhA6t18qj keS4nQKx2bj720fWvFxZ608JWiMH7IJs3pKPM03JGEnAhDHOqwBjIuyMHUzqMrcG7T8t 6Zpq5K3zqFa007gD7BAk3R1MVK3rIJqDbSroKILzJFX/0TFyFu7lrVxY83qH3WfX6a48 A9ig== X-Gm-Message-State: ACgBeo0LM4GygBBS34X2ocqKG3hzSWqLNllWfQyGuedAZeAZ9Y2dhn6y 6ORSeqOVtAESgKWF5jrD4BhlReka/w4= X-Google-Smtp-Source: AA6agR5hR7ug5gYNU9ustu7Hgi9QC2sOgEzcOQh/4Ue2Dn+6uPSZFB4IuuWLM262MFrF4SnogDXv6g== X-Received: by 2002:a05:6000:1a89:b0:21d:ab1a:b177 with SMTP id f9-20020a0560001a8900b0021dab1ab177mr13048745wry.594.1659443388240; Tue, 02 Aug 2022 05:29:48 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c22c700b003a03e63e428sm27333450wmg.36.2022.08.02.05.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 05:29:47 -0700 (PDT) Message-Id: <6a6f1a04889ac475dd9c07e98f2ffc4b677e8e40.1659443384.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 02 Aug 2022 12:29:41 +0000 Subject: [PATCH v2 2/5] bundle-uri: create basic file-copy logic Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, dyroneteng@gmail.com, Johannes.Schindelin@gmx.de, szeder.dev@gmail.com, mjcheetham@outlook.com, steadmon@google.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before implementing a way to fetch bundles into a repository, create the basic logic. Assume that the URI is actually a file path. Future logic will make this more careful to other protocols. For now, we also only succeed if the content at the URI is a bundle file, not a bundle list. Bundle lists will be implemented in a future change. Note that the discovery of a temporary filename is slightly racy because the odb_mkstemp() relies on the temporary file not existing. With the current implementation being limited to file copies, we could replace the copy_file() with copy_fd(). The tricky part comes in future changes that send the filename to 'git remote-https' and its 'get' capability. At that point, we need the file descriptor closed _and_ the file unlinked. If we were to keep the file descriptor open for the sake of normal file copies, then we would pollute the rest of the code for little benefit. This is especially the case because we expect that most bundle URI use will be based on HTTPS instead of file copies. Reviewed-by: Josh Steadmon Signed-off-by: Derrick Stolee --- Makefile | 1 + bundle-uri.c | 104 ++++++++++++++++++++++++++++++++++++++++++++ bundle-uri.h | 14 ++++++ t/t5557-http-get.sh | 2 + 4 files changed, 121 insertions(+) create mode 100644 bundle-uri.c create mode 100644 bundle-uri.h diff --git a/Makefile b/Makefile index 1624471badc..7d5f48069ea 100644 --- a/Makefile +++ b/Makefile @@ -906,6 +906,7 @@ LIB_OBJS += blob.o LIB_OBJS += bloom.o LIB_OBJS += branch.o LIB_OBJS += bulk-checkin.o +LIB_OBJS += bundle-uri.o LIB_OBJS += bundle.o LIB_OBJS += cache-tree.o LIB_OBJS += cbtree.o diff --git a/bundle-uri.c b/bundle-uri.c new file mode 100644 index 00000000000..b35babc36aa --- /dev/null +++ b/bundle-uri.c @@ -0,0 +1,104 @@ +#include "cache.h" +#include "bundle-uri.h" +#include "bundle.h" +#include "object-store.h" +#include "refs.h" +#include "run-command.h" + +static int find_temp_filename(struct strbuf *name) +{ + int fd; + /* + * Find a temporary filename that is available. This is briefly + * racy, but unlikely to collide. + */ + fd = odb_mkstemp(name, "bundles/tmp_uri_XXXXXX"); + if (fd < 0) { + warning(_("failed to create temporary file")); + return -1; + } + + close(fd); + unlink(name->buf); + return 0; +} + +static int copy_uri_to_file(const char *file, const char *uri) +{ + /* File-based URIs only for now. */ + return copy_file(file, uri, 0); +} + +static int unbundle_from_file(struct repository *r, const char *file) +{ + int result = 0; + int bundle_fd; + struct bundle_header header = BUNDLE_HEADER_INIT; + struct string_list_item *refname; + struct strbuf bundle_ref = STRBUF_INIT; + size_t bundle_prefix_len; + + if ((bundle_fd = read_bundle_header(file, &header)) < 0) + return 1; + + if ((result = unbundle(r, &header, bundle_fd, NULL))) + return 1; + + /* + * Convert all refs/heads/ from the bundle into refs/bundles/ + * in the local repository. + */ + strbuf_addstr(&bundle_ref, "refs/bundles/"); + bundle_prefix_len = bundle_ref.len; + + for_each_string_list_item(refname, &header.references) { + struct object_id *oid = refname->util; + struct object_id old_oid; + const char *branch_name; + int has_old; + + if (!skip_prefix(refname->string, "refs/heads/", &branch_name)) + continue; + + strbuf_setlen(&bundle_ref, bundle_prefix_len); + strbuf_addstr(&bundle_ref, branch_name); + + has_old = !read_ref(bundle_ref.buf, &old_oid); + update_ref("fetched bundle", bundle_ref.buf, oid, + has_old ? &old_oid : NULL, + REF_SKIP_OID_VERIFICATION, + UPDATE_REFS_MSG_ON_ERR); + } + + bundle_header_release(&header); + return result; +} + +int fetch_bundle_uri(struct repository *r, const char *uri) +{ + int result = 0; + struct strbuf filename = STRBUF_INIT; + + if ((result = find_temp_filename(&filename))) + goto cleanup; + + if ((result = copy_uri_to_file(filename.buf, uri))) { + warning(_("failed to download bundle from URI '%s'"), uri); + goto cleanup; + } + + if ((result = !is_bundle(filename.buf, 0))) { + warning(_("file at URI '%s' is not a bundle"), uri); + goto cleanup; + } + + if ((result = unbundle_from_file(r, filename.buf))) { + warning(_("failed to unbundle bundle from URI '%s'"), uri); + goto cleanup; + } + +cleanup: + unlink(filename.buf); + strbuf_release(&filename); + return result; +} diff --git a/bundle-uri.h b/bundle-uri.h new file mode 100644 index 00000000000..8a152f1ef14 --- /dev/null +++ b/bundle-uri.h @@ -0,0 +1,14 @@ +#ifndef BUNDLE_URI_H +#define BUNDLE_URI_H + +struct repository; + +/** + * Fetch data from the given 'uri' and unbundle the bundle data found + * based on that information. + * + * Returns non-zero if no bundle information is found at the given 'uri'. + */ +int fetch_bundle_uri(struct repository *r, const char *uri); + +#endif diff --git a/t/t5557-http-get.sh b/t/t5557-http-get.sh index 09fb0bd9a8a..76a4bbd16af 100755 --- a/t/t5557-http-get.sh +++ b/t/t5557-http-get.sh @@ -2,6 +2,8 @@ test_description='test downloading a file by URL' +TEST_PASSES_SANITIZE_LEAK=true + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh From patchwork Tue Aug 2 12:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12934606 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E84C00140 for ; Tue, 2 Aug 2022 12:30:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237117AbiHBMaB (ORCPT ); Tue, 2 Aug 2022 08:30:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237078AbiHBM3w (ORCPT ); Tue, 2 Aug 2022 08:29:52 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 414E15073D for ; Tue, 2 Aug 2022 05:29:51 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id j7so17705337wrh.3 for ; Tue, 02 Aug 2022 05:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=F5mnbe6cQVKNs5hDJq87ao07TTZJ+9EzkJCzIacIGYQ=; b=FBOlM3EpLu3pF0nPa8gWJ1BVKs+TdcLsX9XxaDfM3jpf97i208FEbkqe4W/OeRSVJX R9kDuKHSOkO0s/1HKn8l3R4No9dykC1v4oGTbDWYtEnPei1hbYhf9Sni/HukRZug+jE6 N1uhp+xQ6MeoksMZCYgnw46JFVYtDk8wr0CmRj74iNwVuoy5SXDXdpaq/vmSJ1L2K3Ep fXqh3DoMJLV1szDx2gR9v4sKaIBeHDKjrhjbn4ejWYgJ5OOqiyJIbFyB4nPpf/GC6h04 LCmqJhyEiwvX5CHsyw2ulwxFoJVcmcaO4wYHsRe4CR1ziNZJVTv8V7tCM5Qkbp20pa/1 4Bhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=F5mnbe6cQVKNs5hDJq87ao07TTZJ+9EzkJCzIacIGYQ=; b=yY2nThbAm4+71C28CuaBwGekeaJBMmo5uYVv5gti2Qep5tgxKO8SxskDjMeWOttw63 CDWTwQDfsl2h/N5QvbFIXGR3TeFehLMLgz0oxyvvGJZgpPBUbRfnLmMkd+FFkUaU7ltQ WwD3j6Av/JvWGoNrx9V1C0zqt7b5ljohLXn5lLmpil1AwcTEs09jvkufGZ4f/I+h2l2k af47tcZp/GrgRS3JUFgYL6ixnKIl7nAgVpXyVcfmL5A4yRww8JF81q4ejsl9Kksa9l04 uJPKKH6ksKntt3uGpQky7g7qPLP39V9rDMVHT7EYmzT0PaRWJzOUSfAf2iqs8UqOCNCb VHpw== X-Gm-Message-State: ACgBeo13aY5A+5KbGlt12IkbNXr+0x6FTIcN4bQsleXYqwzrtzTufrXz OiNBRPVoJHJ48uKTSfCiePyMnBBg9Xo= X-Google-Smtp-Source: AA6agR73pSlWUXGTuOQAJhKo6P8a+QJIuJ6/gaTOBIwHp0MA4B2vdNcVfUljcziBh0I6YiUZ6PeqRg== X-Received: by 2002:a05:6000:508:b0:21d:4105:caf9 with SMTP id a8-20020a056000050800b0021d4105caf9mr13175372wrf.699.1659443389373; Tue, 02 Aug 2022 05:29:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c5-20020a05600c0a4500b003a3442f1229sm28763343wmq.29.2022.08.02.05.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 05:29:48 -0700 (PDT) Message-Id: <00debaf6e77852efe1dcad4bfda5ebd5bf590ac4.1659443384.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 02 Aug 2022 12:29:42 +0000 Subject: [PATCH v2 3/5] clone: add --bundle-uri option Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, dyroneteng@gmail.com, Johannes.Schindelin@gmx.de, szeder.dev@gmail.com, mjcheetham@outlook.com, steadmon@google.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Cloning a remote repository is one of the most expensive operations in Git. The server can spend a lot of CPU time generating a pack-file for the client's request. The amount of data can clog the network for a long time, and the Git protocol is not resumable. For users with poor network connections or are located far away from the origin server, this can be especially painful. Add a new '--bundle-uri' option to 'git clone' to bootstrap a clone from a bundle. If the user is aware of a bundle server, then they can tell Git to bootstrap the new repository with these bundles before fetching the remaining objects from the origin server. Reviewed-by: Josh Steadmon Signed-off-by: Derrick Stolee --- Documentation/git-clone.txt | 6 ++++++ builtin/clone.c | 15 +++++++++++++++ t/t5558-clone-bundle-uri.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100755 t/t5558-clone-bundle-uri.sh diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 632bd1348ea..60fedf7eb5e 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -323,6 +323,12 @@ or `--mirror` is given) for `host.xz:foo/.git`). Cloning into an existing directory is only allowed if the directory is empty. +--bundle-uri=:: + Before fetching from the remote, fetch a bundle from the given + `` and unbundle the data into the local repository. The refs + in the bundle will be stored under the hidden `refs/bundle/*` + namespace. + :git-clone: 1 include::urls.txt[] diff --git a/builtin/clone.c b/builtin/clone.c index c4ff4643ecd..4224d562758 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -34,6 +34,7 @@ #include "list-objects-filter-options.h" #include "hook.h" #include "bundle.h" +#include "bundle-uri.h" /* * Overall FIXMEs: @@ -77,6 +78,7 @@ static int option_filter_submodules = -1; /* unspecified */ static int config_filter_submodules = -1; /* unspecified */ static struct string_list server_options = STRING_LIST_INIT_NODUP; static int option_remote_submodules; +static const char *bundle_uri; static int recurse_submodules_cb(const struct option *opt, const char *arg, int unset) @@ -160,6 +162,8 @@ static struct option builtin_clone_options[] = { N_("any cloned submodules will use their remote-tracking branch")), OPT_BOOL(0, "sparse", &option_sparse_checkout, N_("initialize sparse-checkout file to include only files at root")), + OPT_STRING(0, "bundle-uri", &bundle_uri, + N_("uri"), N_("a URI for downloading bundles before fetching from origin remote")), OPT_END() }; @@ -1232,6 +1236,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (transport->smart_options && !deepen && !filter_options.choice) transport->smart_options->check_self_contained_and_connected = 1; + /* + * Before fetching from the remote, download and install bundle + * data from the --bundle-uri option. + */ + if (bundle_uri) { + /* At this point, we need the_repository to match the cloned repo. */ + repo_init(the_repository, git_dir, work_tree); + if (fetch_bundle_uri(the_repository, bundle_uri)) + warning(_("failed to fetch objects from bundle URI '%s'"), + bundle_uri); + } strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD"); refspec_ref_prefixes(&remote->fetch, diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh new file mode 100755 index 00000000000..f709bcb729c --- /dev/null +++ b/t/t5558-clone-bundle-uri.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +test_description='test fetching bundles with --bundle-uri' + +. ./test-lib.sh + +test_expect_success 'fail to clone from non-existent file' ' + test_when_finished rm -rf test && + git clone --bundle-uri="$(pwd)/does-not-exist" . test 2>err && + grep "failed to download bundle from URI" err +' + +test_expect_success 'fail to clone from non-bundle file' ' + test_when_finished rm -rf test && + echo bogus >bogus && + git clone --bundle-uri="$(pwd)/bogus" . test 2>err && + grep "is not a bundle" err +' + +test_expect_success 'create bundle' ' + git init clone-from && + git -C clone-from checkout -b topic && + test_commit -C clone-from A && + test_commit -C clone-from B && + git -C clone-from bundle create B.bundle topic +' + +test_expect_success 'clone with path bundle' ' + git clone --bundle-uri="clone-from/B.bundle" \ + clone-from clone-path && + git -C clone-path rev-parse refs/bundles/topic >actual && + git -C clone-from rev-parse topic >expect && + test_cmp expect actual +' + +test_done From patchwork Tue Aug 2 12:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12934607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B665C19F2C for ; Tue, 2 Aug 2022 12:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237093AbiHBMaD (ORCPT ); Tue, 2 Aug 2022 08:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237080AbiHBM3y (ORCPT ); Tue, 2 Aug 2022 08:29:54 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7966B5141F for ; Tue, 2 Aug 2022 05:29:52 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id i128-20020a1c3b86000000b003a3a22178beso185281wma.3 for ; Tue, 02 Aug 2022 05:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=jl2nmWB2vij0+IeKB6NR48HqFK+MmtvvABQqvCCowmU=; b=TekfyOPvtK1RvTQ0wJ2Oy2eHdNQCU/pbdhRjz+r03BFzmrFgMjjkJjyLcXI20PaFSm 94tC07h7lNynJmcG9aLQqsvipXg59628Ub0zVIpS5kOu1obcQ+AkGk/igQxpRtnt7Kvm u5V5E3H7ZBtHrCzNK2U7fVQHiyMMps0fo1iqNAhKLNhCZgP8vEQYl/yPgSK18PlhnQcU JDKy/PJ8Ic2gVXAP11d++ov8L+WKQZGdv6KLdTMTYfzZZ9igmN99WeOLDNliau5FOGZE +saayroVpnZodL8g/kHetDP34mtOaVFn8WRZtMmjcLf+UzVUxxZVsxtNcyxHIDtfAwR2 J10g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=jl2nmWB2vij0+IeKB6NR48HqFK+MmtvvABQqvCCowmU=; b=TNL4jTdQYRGfCYXDas5utXLQXQDnUEdD/CaOagWwTXaDOCW/DqMwp+KnWw1eXAEs14 8dAZp/cECz4xtAcm+aA6JkxgB+JRH0E3M8P2++tljT/IYEjuWXcU+BrHuNiQuLcM7I/0 NHRIuw6xlj8k2ihir4/GmQo0YnZAujpLbi2Ewu3sQMlbFy19DAVXaDAMPxGQESblfAK9 EOWJ5z02TwKeS/GuNxQt3whlC23FUjy1Q9aEjT5E+7EogWPp2XQpThtkkDZXlOvQ+J1A 6C9sTgQUVxcFei0k9XvZWV/gu0/MpcYg1sm7DXk56sCn54J61/miLqYyMCE1+WgofQMn 1tJQ== X-Gm-Message-State: AJIora/xgfQsrwSNOXYpgOnoWEnS1QbKrnqRb9IJCBlgHeikBgbjfCwx 71RmgucWqN5ck9nx38ASgF8a5hB1CKg= X-Google-Smtp-Source: AGRyM1vP53EMbMaaMtzegTYN6qv6krxIynXjDsYhAGhaDXGM1NfosWaMIFJ5nZ0m9hkiKKIEmdTXOQ== X-Received: by 2002:a05:600c:1001:b0:3a3:a221:78ab with SMTP id c1-20020a05600c100100b003a3a22178abmr14259437wmc.164.1659443390546; Tue, 02 Aug 2022 05:29:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bd15-20020a05600c1f0f00b003a1980d55c4sm23495557wmb.47.2022.08.02.05.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 05:29:50 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 02 Aug 2022 12:29:43 +0000 Subject: [PATCH v2 4/5] bundle-uri: add support for http(s):// and file:// Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, dyroneteng@gmail.com, Johannes.Schindelin@gmx.de, szeder.dev@gmail.com, mjcheetham@outlook.com, steadmon@google.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The previous change created the 'git clone --bundle-uri=' option. Currently, must be a filename. Update copy_uri_to_file() to first inspect the URI for an HTTP(S) prefix and use git-remote-https as the way to download the data at that URI. Otherwise, check to see if file:// is present and modify the prefix accordingly. Reviewed-by: Josh Steadmon Signed-off-by: Derrick Stolee --- bundle-uri.c | 70 +++++++++++++++++++++++++++++++++++-- t/t5558-clone-bundle-uri.sh | 45 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/bundle-uri.c b/bundle-uri.c index b35babc36aa..930e995d194 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -23,10 +23,74 @@ static int find_temp_filename(struct strbuf *name) return 0; } -static int copy_uri_to_file(const char *file, const char *uri) +static int download_https_uri_to_file(const char *file, const char *uri) { - /* File-based URIs only for now. */ - return copy_file(file, uri, 0); + int result = 0; + struct child_process cp = CHILD_PROCESS_INIT; + FILE *child_in = NULL, *child_out = NULL; + struct strbuf line = STRBUF_INIT; + int found_get = 0; + + strvec_pushl(&cp.args, "git-remote-https", "origin", uri, NULL); + cp.in = -1; + cp.out = -1; + + if (start_command(&cp)) + return 1; + + child_in = fdopen(cp.in, "w"); + if (!child_in) { + result = 1; + goto cleanup; + } + + child_out = fdopen(cp.out, "r"); + if (!child_out) { + result = 1; + goto cleanup; + } + + fprintf(child_in, "capabilities\n"); + fflush(child_in); + + while (!strbuf_getline(&line, child_out)) { + if (!line.len) + break; + if (!strcmp(line.buf, "get")) + found_get = 1; + } + strbuf_release(&line); + + if (!found_get) { + result = error(_("insufficient capabilities")); + goto cleanup; + } + + fprintf(child_in, "get %s %s\n\n", uri, file); + +cleanup: + if (child_in) + fclose(child_in); + if (finish_command(&cp)) + return 1; + if (child_out) + fclose(child_out); + return result; +} + +static int copy_uri_to_file(const char *filename, const char *uri) +{ + const char *out; + + if (istarts_with(uri, "https:") || + istarts_with(uri, "http:")) + return download_https_uri_to_file(filename, uri); + + if (!skip_prefix(uri, "file://", &out)) + out = uri; + + /* Copy as a file */ + return copy_file(filename, out, 0); } static int unbundle_from_file(struct repository *r, const char *file) diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh index f709bcb729c..ad666a2d28a 100755 --- a/t/t5558-clone-bundle-uri.sh +++ b/t/t5558-clone-bundle-uri.sh @@ -33,4 +33,49 @@ test_expect_success 'clone with path bundle' ' test_cmp expect actual ' +test_expect_success 'clone with file:// bundle' ' + git clone --bundle-uri="file://$(pwd)/clone-from/B.bundle" \ + clone-from clone-file && + git -C clone-file rev-parse refs/bundles/topic >actual && + git -C clone-from rev-parse topic >expect && + test_cmp expect actual +' + +######################################################################### +# HTTP tests begin here + +. "$TEST_DIRECTORY"/lib-httpd.sh +start_httpd + +test_expect_success 'fail to fetch from non-existent HTTP URL' ' + test_when_finished rm -rf test && + git clone --bundle-uri="$HTTPD_URL/does-not-exist" . test 2>err && + grep "failed to download bundle from URI" err +' + +test_expect_success 'fail to fetch from non-bundle HTTP URL' ' + test_when_finished rm -rf test && + echo bogus >"$HTTPD_DOCUMENT_ROOT_PATH/bogus" && + git clone --bundle-uri="$HTTPD_URL/bogus" . test 2>err && + grep "is not a bundle" err +' + +test_expect_success 'clone HTTP bundle' ' + cp clone-from/B.bundle "$HTTPD_DOCUMENT_ROOT_PATH/B.bundle" && + + git clone --no-local --mirror clone-from \ + "$HTTPD_DOCUMENT_ROOT_PATH/fetch.git" && + + git clone --bundle-uri="$HTTPD_URL/B.bundle" \ + "$HTTPD_URL/smart/fetch.git" clone-http && + git -C clone-http rev-parse refs/bundles/topic >actual && + git -C clone-from rev-parse topic >expect && + test_cmp expect actual && + + test_config -C clone-http log.excludedecoration refs/bundle/ +' + +# Do not add tests here unless they use the HTTP server, as they will +# not run unless the HTTP dependencies exist. + test_done From patchwork Tue Aug 2 12:29:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12934608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56E2AC00140 for ; Tue, 2 Aug 2022 12:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237105AbiHBMaF (ORCPT ); Tue, 2 Aug 2022 08:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237083AbiHBM3y (ORCPT ); Tue, 2 Aug 2022 08:29:54 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F7751422 for ; Tue, 2 Aug 2022 05:29:53 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id m41-20020a05600c3b2900b003a4e094256eso924860wms.0 for ; Tue, 02 Aug 2022 05:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=G8JreIyzcEq7/uAXxPzoccFoQb6CoOWKqrR+In2Ko/0=; b=ZjwkQrPTwsTqCVY6AoX+y7xyXwLToHPKn1+gXlg22sWO2wAJYJpUURUcUj8GdarqlV wgyLzOnpwB1xTekz1Hdsbp7E2dSC3LmouWW8oQaqNUXsyiUYZhJWFo6uivMWaU3tfTiA fQSfOyHmr+sUqhSSjttwocANoCLQ8LEPc5gV5KM9Ob7/7Gbc6axyJ6u3VGQOaJlarIKz SdF8aGEoXAQj1/dbFdtYFo9vLI2AF9/MdMt0dR8tKioEi0V9C9+TFS1ATdKPzlUIrL+h VDiMKFZc9d3yaTkj24VV7NgWCZO5bvffpWYIX10c5KvQWoLvVNtK32k174IknHw3wstm A+hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=G8JreIyzcEq7/uAXxPzoccFoQb6CoOWKqrR+In2Ko/0=; b=aSO3vTzIcFt5wrTIGk1SnbSgD1bpeQdCFBOfSJxMOGDYzZtjECNGmLEzZ2ObS7YbHN ej2nIFSi9kVtqJtxIPivNTS2WnPSuTD8cGItxzyNDkeGmML7V83PQuRvcGJdQ+mC3HSF rsAruxfZvrBxQVbdh7JM3OxKPsbUoY+rc0UGKnA5HAkQuepQ21rucO+h3xTcHDnVQpF9 vvFrCCKo/sxdy+wco4YMmJwvC79xpArkoHXK8XOrtp94HpFeeXF4OcaTWtdA1QvxqPMb /F8zMnjc7ZgDnaCSAQjXTD7EIbp/87i1/PhyZuvXjGv045mYU6U8/HUhHVxR9kH6D5xy X96w== X-Gm-Message-State: AJIora+CbKHnVHpe5TWms7ewpRHlYN2BoTM10PQt8dRcFFzsmpUN4aGZ vPGelARKwZ1NOQY1UDdeeCcTXVLDI2w= X-Google-Smtp-Source: AGRyM1taZAaW62Zu0UCSk3C2/UbUerDekUEkXJ6LDIqzWYV9L5dgWXD3BKt8ZDG+nRVz6+YG4AUPJA== X-Received: by 2002:a05:600c:4113:b0:3a3:4b67:d086 with SMTP id j19-20020a05600c411300b003a34b67d086mr13975832wmi.20.1659443391576; Tue, 02 Aug 2022 05:29:51 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f18-20020a5d50d2000000b0021e9fafa601sm14990033wrt.22.2022.08.02.05.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 05:29:51 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 02 Aug 2022 12:29:44 +0000 Subject: [PATCH v2 5/5] clone: --bundle-uri cannot be combined with --depth Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, dyroneteng@gmail.com, Johannes.Schindelin@gmx.de, szeder.dev@gmail.com, mjcheetham@outlook.com, steadmon@google.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee A previous change added the '--bundle-uri' option, but did not check if the --depth parameter was included. Since bundles are not compatible with shallow clones, provide an error message to the user who is attempting this combination. I am leaving this as its own change, separate from the one that implements '--bundle-uri', because this is more of an advisory for the user. There is nothing wrong with bootstrapping with bundles and then fetching a shallow clone. However, that is likely going to involve too much work for the client _and_ the server. The client will download all of this bundle information containing the full history of the repository only to ignore most of it. The server will get a shallow fetch request, but with a list of haves that might cause a more painful computation of that shallow pack-file. Reviewed-by: Josh Steadmon Signed-off-by: Derrick Stolee --- Documentation/git-clone.txt | 3 ++- builtin/clone.c | 3 +++ t/t5606-clone-options.sh | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 60fedf7eb5e..d032d971dd7 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -327,7 +327,8 @@ or `--mirror` is given) Before fetching from the remote, fetch a bundle from the given `` and unbundle the data into the local repository. The refs in the bundle will be stored under the hidden `refs/bundle/*` - namespace. + namespace. This option is incompatible with `--depth`, + `--shallow-since`, and `--shallow-exclude`. :git-clone: 1 include::urls.txt[] diff --git a/builtin/clone.c b/builtin/clone.c index 4224d562758..4463789680b 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -937,6 +937,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) option_no_checkout = 1; } + if (bundle_uri && deepen) + die(_("--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude")); + repo_name = argv[0]; path = get_repo_path(repo_name, &is_bundle); diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index 8f676d6b0c0..f6bb02ab947 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -58,6 +58,14 @@ test_expect_success 'disallows --bare with --separate-git-dir' ' ' +test_expect_success 'disallows --bundle-uri with shallow options' ' + for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD + do + test_must_fail git clone --bundle-uri=bundle $option from to 2>err && + grep "bundle-uri is incompatible" err || return 1 + done +' + test_expect_success 'reject cloning shallow repository' ' test_when_finished "rm -rf repo" && test_must_fail git clone --reject-shallow shallow-repo out 2>err &&