git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: stolee@gmail.com, avarab@gmail.com, gitster@pobox.com,
	zhiyou.jx@alibaba-inc.com, jonathantanmy@google.com,
	Jeff Hostetler <git@jeffhostetler.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Derrick Stolee <derrickstolee@github.com>
Subject: [PATCH v4 13/13] clone: fail gracefully when cloning filtered bundle
Date: Wed, 09 Mar 2022 16:01:43 +0000	[thread overview]
Message-ID: <de6a1a868d311c1b59bff457fe72ed127a0669bd.1646841704.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1159.v4.git.1646841703.gitgitgadget@gmail.com>

From: Derrick Stolee <derrickstolee@github.com>

Users can create a new repository using 'git clone <bundle-file>'. The
new "@filter" capability for bundles means that we can generate a bundle
that does not contain all reachable objects, even if the header has no
negative commit OIDs.

It is feasible to think that we could make a filtered bundle work with
the command

  git clone --filter=$filter --bare <bundle-file>

or possibly replacing --bare with --no-checkout. However, this requires
having some repository-global config that specifies the specified object
filter and notifies Git about the existence of promisor pack-files.
Without a remote, that is currently impossible.

As a stop-gap, parse the bundle header during 'git clone' and die() with
a helpful error message instead of the current behavior of failing due
to "missing objects".

Most of the existing logic for handling bundle clones actually happens
in fetch-pack.c, but that logic is the same as if the user specified
'git fetch <bundle>', so we want to avoid failing to fetch a filtered
bundle when in an existing repository that has the proper config set up
for at least one remote.

Carefully comment around the test that this is not the desired long-term
behavior of 'git clone' in this case, but instead that we need to do
more work before that is possible.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/clone.c        | 13 +++++++++++++
 t/t6020-bundle-misc.sh | 12 ++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9c29093b352..e57504c2aa8 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -33,6 +33,7 @@
 #include "packfile.h"
 #include "list-objects-filter-options.h"
 #include "hook.h"
+#include "bundle.h"
 
 /*
  * Overall FIXMEs:
@@ -1138,6 +1139,18 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 		warning(_("--local is ignored"));
 	transport->cloning = 1;
 
+	if (is_bundle) {
+		struct bundle_header header = BUNDLE_HEADER_INIT;
+		int fd = read_bundle_header(path, &header);
+		int has_filter = header.filter.choice != LOFC_DISABLED;
+
+		if (fd > 0)
+			close(fd);
+		bundle_header_release(&header);
+		if (has_filter)
+			die(_("cannot clone from filtered bundle"));
+	}
+
 	transport_set_option(transport, TRANS_OPT_KEEP, "yes");
 
 	if (reject_shallow)
diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh
index 7c6db670221..ed95d195427 100755
--- a/t/t6020-bundle-misc.sh
+++ b/t/t6020-bundle-misc.sh
@@ -537,4 +537,16 @@ do
 	'
 done
 
+# NEEDSWORK: 'git clone --bare' should be able to clone from a filtered
+# bundle, but that requires a change to promisor/filter config options.
+# For now, we fail gracefully with a helpful error. This behavior can be
+# changed in the future to succeed as much as possible.
+test_expect_success 'cloning from filtered bundle has useful error' '
+	git bundle create partial.bdl \
+		--all \
+		--filter=blob:none &&
+	test_must_fail git clone --bare partial.bdl partial 2>err &&
+	grep "cannot clone from filtered bundle" err
+'
+
 test_done
-- 
gitgitgadget

      parent reply	other threads:[~2022-03-09 16:04 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 17:55 [PATCH 00/11] Partial bundles Derrick Stolee via GitGitGadget
2022-02-23 17:55 ` [PATCH 01/11] index-pack: document and test the --promisor option Derrick Stolee via GitGitGadget
2022-02-23 17:55 ` [PATCH 02/11] revision: put object filter into struct rev_info Derrick Stolee via GitGitGadget
2022-03-04 22:15   ` Junio C Hamano
2022-03-07 13:59     ` Derrick Stolee
2022-03-07 16:46       ` Junio C Hamano
2022-02-23 17:55 ` [PATCH 03/11] pack-objects: use rev.filter when possible Derrick Stolee via GitGitGadget
2022-03-04 22:25   ` Junio C Hamano
2022-02-23 17:55 ` [PATCH 04/11] pack-bitmap: drop filter in prepare_bitmap_walk() Derrick Stolee via GitGitGadget
2022-03-04 22:26   ` Junio C Hamano
2022-02-23 17:55 ` [PATCH 05/11] list-objects: consolidate traverse_commit_list[_filtered] Derrick Stolee via GitGitGadget
2022-03-04 22:30   ` Junio C Hamano
2022-02-23 17:55 ` [PATCH 06/11] MyFirstObjectWalk: update recommended usage Derrick Stolee via GitGitGadget
2022-03-04 22:33   ` Junio C Hamano
2022-03-07 14:05     ` Derrick Stolee
2022-03-07 16:47       ` Junio C Hamano
2022-02-23 17:55 ` [PATCH 07/11] bundle: safely handle --objects option Derrick Stolee via GitGitGadget
2022-02-28 16:00   ` Jeff Hostetler
2022-03-04 22:58     ` Junio C Hamano
2022-03-07 14:09       ` Derrick Stolee
2022-03-04 22:57   ` Junio C Hamano
2022-03-07 15:35   ` Ævar Arnfjörð Bjarmason
2022-02-23 17:55 ` [PATCH 08/11] bundle: parse filter capability Derrick Stolee via GitGitGadget
2022-03-07 15:38   ` Ævar Arnfjörð Bjarmason
2022-03-07 16:14     ` Derrick Stolee
2022-03-07 16:22       ` Ævar Arnfjörð Bjarmason
2022-03-07 16:29         ` Derrick Stolee
2022-03-07 15:55   ` Ævar Arnfjörð Bjarmason
2022-02-23 17:55 ` [PATCH 09/11] rev-list: move --filter parsing into revision.c Derrick Stolee via GitGitGadget
2022-02-23 17:55 ` [PATCH 10/11] bundle: create filtered bundles Derrick Stolee via GitGitGadget
2022-03-04 23:35   ` Junio C Hamano
2022-03-07 14:14     ` Derrick Stolee
2022-03-07 16:49       ` Junio C Hamano
2022-03-07 15:44   ` Ævar Arnfjörð Bjarmason
2022-02-23 17:55 ` [PATCH 11/11] bundle: unbundle promisor packs Derrick Stolee via GitGitGadget
2022-03-04 23:43   ` Junio C Hamano
2022-03-07 14:48     ` Derrick Stolee
2022-03-07 16:56       ` Junio C Hamano
2022-03-07 18:57         ` Derrick Stolee
2022-03-07 19:40           ` Junio C Hamano
2022-03-07 19:49             ` Derrick Stolee
2022-03-07 19:54               ` Junio C Hamano
2022-03-07 20:20                 ` Derrick Stolee
2022-03-07 21:35                   ` Junio C Hamano
2022-03-07 15:47   ` Ævar Arnfjörð Bjarmason
2022-03-07 16:10     ` Derrick Stolee
2022-02-28 17:00 ` [PATCH 00/11] Partial bundles Jeff Hostetler
2022-02-28 17:54   ` Derrick Stolee
2022-03-01 18:03     ` Jeff Hostetler
2022-03-04 19:19 ` Derrick Stolee
2022-03-07 14:55 ` Ævar Arnfjörð Bjarmason
2022-03-07 14:59   ` Derrick Stolee
2022-03-07 21:50 ` [PATCH v2 00/12] " Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 01/12] index-pack: document and test the --promisor option Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 02/12] revision: put object filter into struct rev_info Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 03/12] pack-objects: use rev.filter when possible Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 04/12] pack-bitmap: drop filter in prepare_bitmap_walk() Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 05/12] list-objects: consolidate traverse_commit_list[_filtered] Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 06/12] MyFirstObjectWalk: update recommended usage Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 07/12] bundle: safely handle --objects option Derrick Stolee via GitGitGadget
2022-03-08  9:37     ` Ævar Arnfjörð Bjarmason
2022-03-08 13:45       ` Derrick Stolee
2022-03-08 13:53         ` Ævar Arnfjörð Bjarmason
2022-03-07 21:50   ` [PATCH v2 08/12] bundle: parse filter capability Derrick Stolee via GitGitGadget
2022-03-08  9:25     ` Ævar Arnfjörð Bjarmason
2022-03-08 13:43       ` Derrick Stolee
2022-03-07 21:50   ` [PATCH v2 09/12] rev-list: move --filter parsing into revision.c Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 10/12] bundle: create filtered bundles Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 11/12] bundle: unbundle promisor packs Derrick Stolee via GitGitGadget
2022-03-07 21:50   ` [PATCH v2 12/12] clone: fail gracefully when cloning filtered bundle Derrick Stolee via GitGitGadget
2022-03-07 22:11   ` [PATCH v2 00/12] Partial bundles Junio C Hamano
2022-03-08 14:39   ` [PATCH v3 " Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 01/12] index-pack: document and test the --promisor option Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 02/12] revision: put object filter into struct rev_info Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 03/12] pack-objects: use rev.filter when possible Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 04/12] pack-bitmap: drop filter in prepare_bitmap_walk() Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 05/12] list-objects: consolidate traverse_commit_list[_filtered] Derrick Stolee via GitGitGadget
2022-03-09 13:24       ` Ævar Arnfjörð Bjarmason
2022-03-08 14:39     ` [PATCH v3 06/12] MyFirstObjectWalk: update recommended usage Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 07/12] list-objects: handle NULL function pointers Ævar Arnfjörð Bjarmason via GitGitGadget
2022-03-08 17:26       ` Junio C Hamano
2022-03-09 13:40         ` Ævar Arnfjörð Bjarmason
2022-03-09 14:16           ` Derrick Stolee
2022-03-09 18:32           ` Junio C Hamano
2022-03-08 14:39     ` [PATCH v3 08/12] bundle: parse filter capability Derrick Stolee via GitGitGadget
2022-03-08 17:29       ` Junio C Hamano
2022-03-09 14:35         ` Derrick Stolee
2022-03-09 13:30       ` Ævar Arnfjörð Bjarmason
2022-03-08 14:39     ` [PATCH v3 09/12] rev-list: move --filter parsing into revision.c Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 10/12] bundle: create filtered bundles Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 11/12] bundle: unbundle promisor packs Derrick Stolee via GitGitGadget
2022-03-08 14:39     ` [PATCH v3 12/12] clone: fail gracefully when cloning filtered bundle Derrick Stolee via GitGitGadget
2022-03-08 16:10       ` Derrick Stolee
2022-03-08 17:19         ` Junio C Hamano
2022-03-09 16:01     ` [PATCH v4 00/13] Partial bundles Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 01/13] index-pack: document and test the --promisor option Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 02/13] list-objects-filter-options: create copy helper Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 03/13] revision: put object filter into struct rev_info Derrick Stolee via GitGitGadget
2022-03-09 18:48         ` Junio C Hamano
2022-03-09 16:01       ` [PATCH v4 04/13] pack-objects: use rev.filter when possible Derrick Stolee via GitGitGadget
2022-03-10 13:11         ` Ævar Arnfjörð Bjarmason
2022-03-10 13:33           ` Derrick Stolee
2022-03-10 14:24             ` Ævar Arnfjörð Bjarmason
2022-03-09 16:01       ` [PATCH v4 05/13] pack-bitmap: drop filter in prepare_bitmap_walk() Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 06/13] list-objects: consolidate traverse_commit_list[_filtered] Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 07/13] MyFirstObjectWalk: update recommended usage Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 08/13] list-objects: handle NULL function pointers Ævar Arnfjörð Bjarmason via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 09/13] bundle: parse filter capability Derrick Stolee via GitGitGadget
2022-03-09 18:41         ` Junio C Hamano
2022-03-09 18:55           ` Derrick Stolee
2022-03-09 16:01       ` [PATCH v4 10/13] rev-list: move --filter parsing into revision.c Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 11/13] bundle: create filtered bundles Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` [PATCH v4 12/13] bundle: unbundle promisor packs Derrick Stolee via GitGitGadget
2022-03-09 16:01       ` Derrick Stolee via GitGitGadget [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de6a1a868d311c1b59bff457fe72ed127a0669bd.1646841704.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=stolee@gmail.com \
    --cc=zhiyou.jx@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).