From 625e7f148e46c7e09f817ce6ab25f14d4e753f1e Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Mon, 21 Sep 2020 20:03:56 -0700 Subject: [PATCH 1/2] promisor-remote: remove unused variable The variable core_partial_clone_filter_default has been unused since fa3d1b63e8 ("promisor-remote: parse remote.*.partialclonefilter", 2019-06-25), when Git was changed to refer to remote.*.partialclonefilter as the default filter when fetching in a partial clone, but (perhaps inadvertently) there was no fallback to core.partialclonefilter. One alternative is to add the fallback, but the aforementioned change was made more than a year ago and I have not heard of any complaints regarding this matter. In addition, there is currently no mention of core.partialclonefilter in the user documentation. So it seems best to reaffirm that Git will only support remote.*.partialclonefilter. Signed-off-by: Jonathan Tan Signed-off-by: Junio C Hamano --- promisor-remote.c | 5 ----- promisor-remote.h | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/promisor-remote.c b/promisor-remote.c index 6530e26f98..3c572b1c81 100644 --- a/promisor-remote.c +++ b/promisor-remote.c @@ -6,7 +6,6 @@ #include "strvec.h" static char *repository_format_partial_clone; -static const char *core_partial_clone_filter_default; void set_repository_format_partial_clone(char *partial_clone) { @@ -100,10 +99,6 @@ static int promisor_remote_config(const char *var, const char *value, void *data size_t namelen; const char *subkey; - if (!strcmp(var, "core.partialclonefilter")) - return git_config_string(&core_partial_clone_filter_default, - var, value); - if (parse_config_key(var, "remote", &name, &namelen, &subkey) < 0) return 0; diff --git a/promisor-remote.h b/promisor-remote.h index 6343c47d18..c7a14063c5 100644 --- a/promisor-remote.h +++ b/promisor-remote.h @@ -9,7 +9,7 @@ struct object_id; * Promisor remote linked list * * Information in its fields come from remote.XXX config entries or - * from extensions.partialclone or core.partialclonefilter. + * from extensions.partialclone. */ struct promisor_remote { struct promisor_remote *next; From 23547c40518ac04a20acf2f688114f5d97b61f24 Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Mon, 28 Sep 2020 15:26:38 -0700 Subject: [PATCH 2/2] fetch: do not override partial clone filter When a fetch with the --filter argument is made, the configured default filter is set even if one already exists. This change was made in 5e46139376 ("builtin/fetch: remove unique promisor remote limitation", 2019-06-25) - in particular, changing from: * If this is the FIRST partial-fetch request, we enable partial * on this repo and remember the given filter-spec as the default * for subsequent fetches to this remote. to: * If this is a partial-fetch request, we enable partial on * this repo if not already enabled and remember the given * filter-spec as the default for subsequent fetches to this * remote. (The given filter-spec is "remembered" even if there is already an existing one.) This is problematic whenever a lazy fetch is made, because lazy fetches are made using "git fetch --filter=blob:none", but this will also happen if the user invokes "git fetch --filter=" manually. Therefore, restore the behavior prior to 5e46139376, which writes a filter-spec only if the current fetch request is the first partial-fetch one (for that remote). Signed-off-by: Jonathan Tan Signed-off-by: Junio C Hamano --- builtin/fetch.c | 2 +- list-objects-filter-options.c | 10 +++++++++- t/t5601-clone.sh | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index c555836937..97930f8201 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1677,7 +1677,7 @@ static inline void fetch_one_setup_partial(struct remote *remote) * If this is a partial-fetch request, we enable partial on * this repo if not already enabled and remember the given * filter-spec as the default for subsequent fetches to this - * remote. + * remote if there is currently no default filter-spec. */ if (filter_options.choice) { partial_clone_register(remote->name, &filter_options); diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index b66314560a..defd3dfd10 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -344,11 +344,19 @@ void partial_clone_register( const char *remote, struct list_objects_filter_options *filter_options) { + struct promisor_remote *promisor_remote; char *cfg_name; char *filter_name; /* Check if it is already registered */ - if (!promisor_remote_find(remote)) { + if ((promisor_remote = promisor_remote_find(remote))) { + if (promisor_remote->partial_clone_filter) + /* + * Remote is already registered and a filter is already + * set, so we don't need to do anything here. + */ + return; + } else { if (upgrade_repository_format(1) < 0) die(_("unable to upgrade repository format to support partial clone")); diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 15fb64c18d..4631f019fe 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -669,7 +669,8 @@ test_expect_success 'partial clone' ' test_expect_success 'partial clone with -o' ' partial_clone_server server && - git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client + git clone -o blah --filter=blob:limit=0 "file://$(pwd)/server" client && + test_cmp_config -C client "blob:limit=0" --get-all remote.blah.partialclonefilter ' test_expect_success 'partial clone: warn if server does not support object filtering' '