Subject: [PATCH] fetch: allow adding a filter after initial clone.

From: Xin Li <[email-masked]>
Date: Wed, 13 May 2020 13:00:40 -0700

Signed-off-by: Xin Li <[email-masked]>
---
 builtin/fetch.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 3ae52c015d..e5faa17ecd 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1790,8 +1790,16 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	if (depth || deepen_since || deepen_not.nr)
 		deepen = 1;
 
-	if (filter_options.choice && !has_promisor_remote())
-		die("--filter can only be used when extensions.partialClone is set");
+	if (filter_options.choice && !has_promisor_remote()) {
+		char repo_version_string[10];
+
+		xsnprintf(repo_version_string, sizeof(repo_version_string),
+			  "%d", (int)GIT_REPO_VERSION);
+		git_config_set("core.repositoryformatversion",
+			repo_version_string);
+		git_config_set("extensions.partialclone", "origin");
+		promisor_remote_reinit();
+	}
 
 	if (all) {
 		if (argc == 1)
-- 
2.26.2.645.ge9eca65c58-goog