From patchwork Mon Jul 25 20:34:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12928393 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 B0CABC43334 for ; Mon, 25 Jul 2022 20:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237191AbiGYUep (ORCPT ); Mon, 25 Jul 2022 16:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiGYUem (ORCPT ); Mon, 25 Jul 2022 16:34:42 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B86822B04 for ; Mon, 25 Jul 2022 13:34:41 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id u14-20020a05600c00ce00b003a323062569so7039258wmm.4 for ; Mon, 25 Jul 2022 13:34:41 -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=PL/XJobI5xVcWtGY+GITFHenF1J7M/0SWg4QdXJXehs=; b=PEGUQq9zyDQUtog9T7tL6CyfA/lerkt1V/haDG36Qb7YXUC3J7JwVyuSnmvS2RitLv H4O5JnQx1QLHAEauGYQBAYhhxVrEk4VHUQf+C3aOxsFiCgvvUVKms01YfB6umUZoJ9Nd 8dG/i8+mmwwN8TxPRvgS/FUx43Xpj8EWlSwXtjOcuUIyLbsDrjF27P/dKAYPgVxAUwrf qEAv3ZAZcaFs8uZtARhUhn8+mogkuZMlIJsBsK2H+VpOeKTW9Zsb24UvISaK4uSK9s0T 3GWGem8sM0rVgFthGF75+9r2iHek+vJ5byj38LwPoPp1EATPpzI2/AVLX7+lAZpvAxKI vjZg== 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=PL/XJobI5xVcWtGY+GITFHenF1J7M/0SWg4QdXJXehs=; b=EfTxoxWcKFGpFUy8lUcm4w4Ps8NCInx5WbRLAIbsU2JtyLd84V1T8Potkg8kbueedL QWpxdP3rMRFlasXap90v8yFA+iCNfFI1+kug9R3up4DysOF5uDb/Tq79ot6ANKFr/346 Wx1aEygbQDK7PxrsrceZR26WIN/DpaRyGL04OdMtJyFykqdS+r6m+FAbr0D4CAbKFGur /8gjDIZwEj7RiSvztE1h/Ji9xq8jLWuZ8tDboRrySU7cvGddpXTVAMNtTv6SbthsUepz 5ZCrlD2Y0RMw4806vqvRobK8V+0+symVo7q02rnHQtQkBd91kTlbJ7ss8IjfWiW+TxPS 3crA== X-Gm-Message-State: AJIora/L/lk0O0SyU3Jt/3Dpq2/VRqRIE+bxzb8w+d3nE0ny0uzryrr+ QGpGcou5ygwKloZxtH1H9/O3wfJ19wU= X-Google-Smtp-Source: AGRyM1veHh3avX/del4v++D7sBbehxtKH2f5YzN8lYMOurex2MXdu3iRVQsno2YSqsdW5PN9LnCp/A== X-Received: by 2002:a05:600c:6009:b0:3a3:1506:f60f with SMTP id az9-20020a05600c600900b003a31506f60fmr21699255wmb.144.1658781279650; Mon, 25 Jul 2022 13:34:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0021e50971147sm12610362wrl.44.2022.07.25.13.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 13:34:38 -0700 (PDT) Message-Id: <40808e92afb7bcf3e8e9b4b53d5e30b5e17816f8.1658781277.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 25 Jul 2022 20:34:33 +0000 Subject: [PATCH 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 . Signed-off-by: Derrick Stolee --- Documentation/gitremote-helpers.txt | 9 +++++++ remote-curl.c | 32 +++++++++++++++++++++++++ t/t5557-http-get.sh | 37 +++++++++++++++++++++++++++++ 3 files changed, 78 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..73fbdbddd84 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1286,6 +1286,33 @@ static void parse_fetch(struct strbuf *buf) strbuf_reset(buf); } +static void parse_get(struct strbuf *buf) +{ + 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 ' ', missing space")); + + strbuf_add(&url, p, space - p); + 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); + strbuf_reset(buf); +} + static int push_dav(int nr_spec, const char **specs) { struct child_process child = CHILD_PROCESS_INIT; @@ -1564,9 +1591,14 @@ int cmd_main(int argc, const char **argv) printf("unsupported\n"); fflush(stdout); + } else if (skip_prefix(buf.buf, "get ", &arg)) { + parse_get(&buf); + 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..50b7dbcf957 --- /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' ' + 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 && + rm file1.temp +' + +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_TRACE2_PERF=1 git remote-http $url X-Patchwork-Id: 12928394 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 39129CCA48A for ; Mon, 25 Jul 2022 20:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237183AbiGYUes (ORCPT ); Mon, 25 Jul 2022 16:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbiGYUen (ORCPT ); Mon, 25 Jul 2022 16:34:43 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D563C2251F for ; Mon, 25 Jul 2022 13:34:42 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id z13so17568669wro.13 for ; Mon, 25 Jul 2022 13:34:42 -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=5e3esZlfRS33aCkQSz7epEvmqoy81/tkXXzjsqBAWFA=; b=Sm6MMtJ6J1Jug2oUkEFZRqIUgzGbgpI/SfOZR7zfd+3U+yFA8OjEmqivEv5AhAV+IV MQj6wAa84W3LHIM0NveKyVgWVYcvdhdSbCZ7UBaUvKprW7wpQwvwek6yjnHI+kkww+ka j48DWl5eMr/1fu6mF+lyvMFy7Ka/4zLACUYRjtcFgDbZu1CCpEPKHmBujcsUPHAnz0Jl 5m52Ywar3MAKOyXU/OSaZMzNpmlcj2CyoSerEfMEVWs8AXPQj+2JOFAqfPJmX3yxXTfJ mODKhslJfGkz9Xhq1euGT3i2QdQlfCT1Ri4phztTzghkHV95Zz35fZsgvqp0YH9iCF9E u7tA== 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=5e3esZlfRS33aCkQSz7epEvmqoy81/tkXXzjsqBAWFA=; b=3uoXgiyxfxtbtb+RRchsD/gMtnwHPe30nXhNHysFl6qj8K51zN2Uxbc/eDZTEA13xg k0nX8CuFk5TE7s+ZdVOVuEDKcXu9kpI8PUQm6I6GlwjaGoqCukGjnbX+QXR6IfQBM4N/ 98pruzLiyUfoYuwBIMtW3f9T+HRyU0Vh97ovqX9sUradDSQOLKFWUclyYi7M7sC3PTnu 50lzXvU6LhdMhGWLBT37evQsG7ZNbVZHw9BWJcTVo9TEKqBCWgHqcRW1D3cvUBRhk9/C bc3f5xhqAm9kJijvOwL+2gUO3Uxt3J7Sft2aU8w56Sd+lDuoxzaFHP6oVsf4OTpp7AMY VDEw== X-Gm-Message-State: AJIora/kER/ohRcIcLoOoSX2LpiHy/hCAGx1iNZP7r09vYOMWFDtGINq rISuV2s3+zickoyGOZk30o86oOKXJHk= X-Google-Smtp-Source: AGRyM1sVLpJ0Uc6L9zNGYAgLevQ6zGlnURVO6ZUHfHUBLexyTditW0qagTEDL36Bp7iIB+9f897LUQ== X-Received: by 2002:adf:ee4b:0:b0:21e:8e1a:8f3c with SMTP id w11-20020adfee4b000000b0021e8e1a8f3cmr3119469wro.346.1658781280835; Mon, 25 Jul 2022 13:34:40 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 9-20020a05600c22c900b003a3270735besm15459002wmg.28.2022.07.25.13.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 13:34:40 -0700 (PDT) Message-Id: <7d3159f0d9a29a04b5856982f787f4eddfb91b53.1658781277.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 25 Jul 2022 20:34:34 +0000 Subject: [PATCH 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. Signed-off-by: Derrick Stolee --- Makefile | 1 + bundle-uri.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ bundle-uri.h | 14 +++++++ 3 files changed, 119 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 From patchwork Mon Jul 25 20:34:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12928395 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 1FF14C43334 for ; Mon, 25 Jul 2022 20:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237192AbiGYUe4 (ORCPT ); Mon, 25 Jul 2022 16:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237190AbiGYUep (ORCPT ); Mon, 25 Jul 2022 16:34:45 -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 DD20522531 for ; Mon, 25 Jul 2022 13:34:43 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id ay11-20020a05600c1e0b00b003a3013da120so10135642wmb.5 for ; Mon, 25 Jul 2022 13:34:43 -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=Pp2imNt3nzqwH+MIUUEUHRCp3LeL/HE79H76Q2NiGgw=; b=YVb58r5hJPfBVgx3weCvdbL+4fgY2QgCiALaSjfI4g4VF+qa8OGXGVYMBAl7OEHXJa hVn7kth676Gt6BRZQLcGnymk2p4yI0wnSDcdrbrpUmL9lHCsB2jwx6TUrdnbFBaac+pX AO55ndGrFDSvaS9p8LjfIYupN4Jvfja2eNmwPZ24NmE+HrS6/+lXEdgIyKJyiH7z84uq 26NRcNdIgxyTW2W9Icg5jKh3saihz81XQaHmz4A3R4IunnlwO8S9989VMGeNtMMhpyhF u54MdiE2DY7KRYFo7iYhLDULw8k95SG91euut5ld58wPLlfBRGwZ5MlvVafcXFnaAYI/ cWNg== 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=Pp2imNt3nzqwH+MIUUEUHRCp3LeL/HE79H76Q2NiGgw=; b=qRNRvDMw0W17qr08y+tHA46MvOTe/iJXXzzVfUgnWAOEh6BjlQkrC+Wjr9a5q+/0lI 6BFsL56yCUilWv+aiHSyP9rct4orR5IfyIsPYMtbQxvK5yzVhlVbsCFF2bih+J87lKk1 ikVSFn+DBIggAz4QUPI0EBkTSs+VCoV7xQseeW8wgjqLNaQ/9nwxhwlYZMesj8/LPVw0 38MmY9Waj9MBOvjgaaGyn87bRl80A+IXiVCbFFls2qs9SpdIwvTcB+hrw1GpDwtgGYu+ 4aetzUEnwtFe8l0VscwWdZ5f01bqy4EPtigw4qV9oJLWm447O7RmHP6tw0J6cHe7d7tk dtMg== X-Gm-Message-State: AJIora/pBLxPPSVf9zEAs0uw7J0a7qBVZHiotv85ZJJ5CGiCbtcEuVFw TaZpkQ+U02IF6JNa6Z+RTUKdhJXbOb8= X-Google-Smtp-Source: AGRyM1uP5CIPQETiTwaXaHf4XaouFWNIi3EJKOtHlqXnZyqQVHUgG0Mw8ZsaWV5un2N9pfJINPCtRQ== X-Received: by 2002:a05:600c:1e21:b0:3a3:27b9:8c00 with SMTP id ay33-20020a05600c1e2100b003a327b98c00mr23096360wmb.138.1658781282020; Mon, 25 Jul 2022 13:34:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m184-20020a1c26c1000000b003a04722d745sm19720784wmm.23.2022.07.25.13.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 13:34:41 -0700 (PDT) Message-Id: <29e645a54ba7f6f5d2bcd0590d0ba747ef18fef6.1658781277.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 25 Jul 2022 20:34:35 +0000 Subject: [PATCH 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. 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 Mon Jul 25 20:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12928397 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 EB264C43334 for ; Mon, 25 Jul 2022 20:35:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237204AbiGYUe6 (ORCPT ); Mon, 25 Jul 2022 16:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237198AbiGYUey (ORCPT ); Mon, 25 Jul 2022 16:34:54 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3694D22B16 for ; Mon, 25 Jul 2022 13:34:45 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id ay11-20020a05600c1e0b00b003a3013da120so10135668wmb.5 for ; Mon, 25 Jul 2022 13:34:44 -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=C61v+GzyIPI4XXR/NeNceaeEZ7oq7/iPOtUzMcXWCvI=; b=W0M4fed7ph1fnOik/t08EzccrcPtKCm7MoYZTpF0qXgvr5zJr3LT70lazW/tQLivfQ fYxAv8B26gxqiE6pq1Bw4ZLuYTklTeiMflBDXMGrzNQFZJiCpOQlZPWnbnGys60gTxO3 99Lm5C1ehE/cPoM3eAB6D7FlK0Tn3fOCfFJCsYxnub9gCMnmRWEySBK2Sfzke4a3ZqKV SI20Nt1CNqZB0j1fzCHt6Eug/m9z7x0HOwT2Ndre9etKXlZkx5aaRhtmb5rFxRk9Oe9Q O7cIHGJQ0ES6yglCPLXgCRO8c4Fhw6jNBxEJSyrqPHCzL5fuUljOIwaNqCyJrNERcTg6 9hmw== 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=C61v+GzyIPI4XXR/NeNceaeEZ7oq7/iPOtUzMcXWCvI=; b=FPB5qY13K36vjTmtFgLh9cMWW3P+uSFzbsRxi/bQ0a5YnijbDuTNgBlr/HzRkC0fPQ HdeceN5dccPFkx3+N78HSaborAyESmcGJPlpHcVFkcnPEKvG6SolR9KSbU4bZZssi+Oz BBgiNSRr/EP3D7BRpLiYGX7Q3EYiayPopAxn+qqP++If9yLRbU/0uW//N/UZfj/rnEDk Uox9+/s2ZTlnUZUjglJWojJcfWRsCCZFhCjLn/f0xyGsLbhz1cK+kMktwqppmRaBWLja JvhpZFdTkYk+PYiCM5wJ6IAIIBRu/oTdvjjFgMXGyQmzo3xBUO6QvqP3CBXOyN/JAtbA t8yA== X-Gm-Message-State: AJIora8ir2Q9IPoRtCYv5Z/CwH6WI2ky39LEUf/zhDwm3UmC6rJxR48I 9kAEwDSgon83+t0zX/VDvPjVJXd5ObA= X-Google-Smtp-Source: AGRyM1tArN4Cqfzxs+C2HSwvygZkFH3YNmLLGoo3Bjs/P+KCPhyTjkt43DQ6XNLcF1JI2yKtGMSzAQ== X-Received: by 2002:a7b:ce13:0:b0:3a3:102c:23d3 with SMTP id m19-20020a7bce13000000b003a3102c23d3mr9423835wmc.67.1658781283134; Mon, 25 Jul 2022 13:34:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k7-20020a7bc407000000b003a32251c3f0sm16149738wmi.33.2022.07.25.13.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 13:34:42 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 25 Jul 2022 20:34:36 +0000 Subject: [PATCH 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. 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..7086382b186 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 (skip_prefix(uri, "https:", &out) || + skip_prefix(uri, "http:", &out)) + 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 Mon Jul 25 20:34:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12928396 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 488B9CCA48A for ; Mon, 25 Jul 2022 20:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbiGYUe5 (ORCPT ); Mon, 25 Jul 2022 16:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237195AbiGYUes (ORCPT ); Mon, 25 Jul 2022 16:34:48 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC8B22B28 for ; Mon, 25 Jul 2022 13:34:46 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id bn9so6693096wrb.9 for ; Mon, 25 Jul 2022 13:34:46 -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=BWV2J+OEqm+FLFkss7C1WYGe4M6nDiAYaVnQ7Kr4OLE=; b=mqB7H49m06lRx6AU+IgSUMlwkgipJEldUtdDhnQhPnUZUhbeXfFreXkE8Gau3mtULD 6QdCWpFaR59mzrNjFZQsGek7ts8rsXhju/ZzzidGPOJPj38dgCkx3Ykxxs1r5RaQfRoO jEHYP+JIKXag8nYthWwBPWl8Qp4MfRKLQcpbzFTzATv9M+1Ujs5vHNpB7d0apQNPdBgj gOiPT84bDsOo9CLtgXBHVi7Js1WNq5QrUSfUYrVjQ6dpwr2/lssTxHpmg0Ul8xSHnT8u 1/j9itEO3yTdJZKEDIPqniJHg/8t4kYGDIvVQ78hVR4alyPMbSAxZbLZ2oBAos9s4yNF 3MUQ== 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=BWV2J+OEqm+FLFkss7C1WYGe4M6nDiAYaVnQ7Kr4OLE=; b=Upl+zOYDgPIEFLOUP4aXutftjv8eQTL4fFu+Hex5p3qQyYXAbAejxP72M54e42LY1j W99oatFhVwCU7+Q+NMuakz2i8MeS8fu95eaIfNpJ6d/H1gj1AdzffxfCRQZ4V8KzDwbL WfNJhgbnXtY1MlgQGcjaewEpK6h7rYp7FdpjCBNsTRSeSXTXKWpEaLMCNR1MYSPZF4n1 /xsqztAGcJMp8i1wfCnGpXfGnjGJgwfRyrmtxCxS29/AOiiq/YrW3JzyeNrmZc+1aftc 6HgqmHaJV4Wh1CWgdpisriF/nVG8460EJ3u6RNxx11/g+5GHdDxsVcZiRXWHjzzuMaeJ Bv8g== X-Gm-Message-State: AJIora9XARnVX8YkZLvf7PjsR7rq5PxrdCFZimhj0tQ0+WjY+rdeQGMv kxQ5Rq1ewt8XdGuj/B60l5m9T9Zh23o= X-Google-Smtp-Source: AGRyM1vqN109kdAs+EvyvjLt0/4FBYGUtbTgQepfFngQ5q9isDvhLD6wTIahU03l4DNhhnVXTADQjg== X-Received: by 2002:a5d:5244:0:b0:21d:866e:2409 with SMTP id k4-20020a5d5244000000b0021d866e2409mr8491454wrc.400.1658781284268; Mon, 25 Jul 2022 13:34:44 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t11-20020a5d460b000000b0021b970a68f9sm12452391wrq.26.2022.07.25.13.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 13:34:43 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 25 Jul 2022 20:34:37 +0000 Subject: [PATCH 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. 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 &&