diff --git a/builtin/fetch.c b/builtin/fetch.c index d5bf526277..25fa1cf931 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -1684,7 +1684,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/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; diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index b6c8312da1..7df3c5373a 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -683,7 +683,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' '