From: "John Giorshev via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>,
John Giorshev <john.giorshev1@gmail.com>,
John Giorshev <john.giorshev1@gmail.com>
Subject: [PATCH] add --must-filter option for fetch and clone
Date: Sat, 01 Mar 2025 21:07:22 +0000 [thread overview]
Message-ID: <pull.1869.git.1740863242815.gitgitgadget@gmail.com> (raw)
From: John Giorshev <john.giorshev1@gmail.com>
Signed-off-by: John Giorshev <john.giorshev1@gmail.com>
---
add --must-filter, give error on filter not supported instead of warn
from:
https://public-inbox.org/git/20250225013227.GB752084@coredump.intra.peff.net/
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1869%2Fjagprog5%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1869/jagprog5/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1869
builtin/clone.c | 6 ++++++
builtin/fetch.c | 7 ++++++-
fetch-pack.c | 8 ++++++--
fetch-pack.h | 1 +
t/t0410-partial-clone.sh | 17 +++++++++++++++++
transport.c | 1 +
transport.h | 1 +
7 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index f9a2ecbe9cc..7000b0ecd36 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -887,6 +887,7 @@ int cmd_clone(int argc,
enum ref_storage_format ref_storage_format = REF_STORAGE_FORMAT_UNKNOWN;
const int do_not_override_repo_unix_permissions = -1;
int option_reject_shallow = -1; /* unspecified */
+ int must_filter = 0;
int deepen = 0;
char *option_template = NULL, *option_depth = NULL, *option_since = NULL;
char *option_origin = NULL;
@@ -915,6 +916,8 @@ int cmd_clone(int argc,
N_("force progress reporting")),
OPT_BOOL(0, "reject-shallow", &option_reject_shallow,
N_("don't clone shallow repository")),
+ OPT_BOOL(0, "must-filter", &must_filter,
+ N_("error on filter not supported by server")),
OPT_BOOL('n', "no-checkout", &option_no_checkout,
N_("don't create a checkout")),
OPT_BOOL(0, "bare", &option_bare, N_("create a bare repository")),
@@ -1333,6 +1336,9 @@ int cmd_clone(int argc,
transport_set_verbosity(transport, option_verbosity, option_progress);
transport->family = family;
transport->cloning = 1;
+ if (transport->smart_options) {
+ transport->smart_options->must_filter = must_filter;
+ }
if (is_bundle) {
struct bundle_header header = BUNDLE_HEADER_INIT;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1c740d5aac3..1f3cdf53148 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -84,7 +84,7 @@ static int prune_tags = -1; /* unspecified */
static int append, dry_run, force, keep, update_head_ok;
static int write_fetch_head = 1;
-static int verbosity, deepen_relative, set_upstream, refetch;
+static int verbosity, deepen_relative, set_upstream, refetch, must_filter;
static int progress = -1;
static int tags = TAGS_DEFAULT, update_shallow, deepen;
static int atomic_fetch;
@@ -1508,6 +1508,9 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
transport = transport_get(remote, NULL);
transport_set_verbosity(transport, verbosity, progress);
transport->family = family;
+ if (transport->smart_options) {
+ transport->smart_options->must_filter = must_filter;
+ }
if (upload_pack)
set_option(transport, TRANS_OPT_UPLOADPACK, upload_pack);
if (keep)
@@ -2322,6 +2325,8 @@ int cmd_fetch(int argc,
N_("append to .git/FETCH_HEAD instead of overwriting")),
OPT_BOOL(0, "atomic", &atomic_fetch,
N_("use atomic transaction to update references")),
+ OPT_BOOL(0, "must-filter", &must_filter,
+ N_("error on filter not supported by server")),
OPT_STRING(0, "upload-pack", &upload_pack, N_("path"),
N_("path to upload pack on remote end")),
OPT__FORCE(&force, N_("force overwrite of local reference"), 0),
diff --git a/fetch-pack.c b/fetch-pack.c
index 1ed5e11dd56..0cf59c1bc82 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -319,9 +319,13 @@ static void send_filter(struct fetch_pack_args *args,
trace2_data_string("fetch", the_repository,
"filter/effective", spec);
} else {
- warning("filtering not recognized by server, ignoring");
- trace2_data_string("fetch", the_repository,
+ if (args->must_filter) {
+ die("filtering not recognized by server");
+ } else {
+ warning("filtering not recognized by server, ignoring");
+ trace2_data_string("fetch", the_repository,
"filter/unsupported", spec);
+ }
}
} else {
trace2_data_string("fetch", the_repository,
diff --git a/fetch-pack.h b/fetch-pack.h
index 9d3470366f8..01ab94fc24b 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -40,6 +40,7 @@ struct fetch_pack_args {
unsigned cloning:1;
unsigned update_shallow:1;
unsigned reject_shallow_remote:1;
+ unsigned must_filter:1;
unsigned deepen:1;
unsigned refetch:1;
diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh
index 2a5bdbeeb87..0166c491ca5 100755
--- a/t/t0410-partial-clone.sh
+++ b/t/t0410-partial-clone.sh
@@ -48,6 +48,23 @@ test_expect_success 'convert shallow clone to partial clone' '
test_cmp_config -C client 1 core.repositoryformatversion
'
+test_expect_failure 'must filter clone' '
+ rm -fr server client &&
+ test_create_repo server &&
+ test_commit -C server my_commit 1 &&
+ test_commit -C server my_commit2 1 &&
+ git clone --filter="blob:none" --must-filter "file://$(pwd)/server" client
+'
+
+test_expect_failure 'must filter fetch' '
+ rm -fr server client &&
+ test_create_repo server &&
+ test_commit -C server my_commit 1 &&
+ test_commit -C server my_commit2 1 &&
+ git clone --depth=1 "file://$(pwd)/server" client &&
+ git -C client fetch --unshallow --filter="blob:none" --must-filter
+'
+
test_expect_success DEFAULT_REPO_FORMAT 'convert to partial clone with noop extension' '
rm -fr server client &&
test_create_repo server &&
diff --git a/transport.c b/transport.c
index 6c2801bcbd9..0543821399d 100644
--- a/transport.c
+++ b/transport.c
@@ -450,6 +450,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.quiet = (transport->verbose < 0);
args.no_progress = !transport->progress;
args.depth = data->options.depth;
+ args.must_filter = data->options.must_filter;
args.deepen_since = data->options.deepen_since;
args.deepen_not = data->options.deepen_not;
args.deepen_relative = data->options.deepen_relative;
diff --git a/transport.h b/transport.h
index 44100fa9b7f..0ffc8d273ab 100644
--- a/transport.h
+++ b/transport.h
@@ -16,6 +16,7 @@ struct git_transport_options {
unsigned reject_shallow : 1;
unsigned deepen_relative : 1;
unsigned refetch : 1;
+ unsigned must_filter : 1;
/* see documentation of corresponding flag in fetch-pack.h */
unsigned from_promisor : 1;
base-commit: a554262210b4a2ee6fa2d594e1f09f5830888c56
--
gitgitgadget
next reply other threads:[~2025-03-01 21:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 21:07 John Giorshev via GitGitGadget [this message]
[not found] <DM6PR10MB36907032718A4340FAC6088EAFCB2@DM6PR10MB3690.namprd10.prod.outlook.com>
2025-03-31 15:34 ` [PATCH] add --must-filter option for fetch and clone John Giorshev
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1869.git.1740863242815.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=john.giorshev1@gmail.com \
--cc=peff@peff.net \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.