Skip to content

Commit 01bbbbd

Browse files
delphijgitster
authored andcommitted
fetch: allow adding a filter after initial clone
Retroactively adding a filter can be useful for existing shallow clones as they allow users to see earlier change histories without downloading all git objects in a regular --unshallow fetch. Without this patch, users can make a clone partial by editing the repository configuration to convert the remote into a promisor, like:   git config core.repositoryFormatVersion 1   git config extensions.partialClone origin   git fetch --unshallow --filter=blob:none origin Since the hard part of making this work is already in place and such edits can be error-prone, teach Git to perform the required configuration change automatically instead. Note that this change does not modify the existing git behavior which recognizes setting extensions.partialClone without changing repositoryFormatVersion. Signed-off-by: Xin Li <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16af5f1 commit 01bbbbd

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

builtin/fetch.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,9 +1790,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
17901790
if (depth || deepen_since || deepen_not.nr)
17911791
deepen = 1;
17921792

1793-
if (filter_options.choice && !has_promisor_remote())
1794-
die("--filter can only be used when extensions.partialClone is set");
1795-
17961793
if (all) {
17971794
if (argc == 1)
17981795
die(_("fetch --all does not take a repository argument"));

t/t0410-partial-clone.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ test_expect_success 'extensions.partialclone without filter' '
3030
git -C client fetch origin
3131
'
3232

33+
test_expect_success 'convert shallow clone to partial clone' '
34+
rm -fr server client &&
35+
test_create_repo server &&
36+
test_commit -C server my_commit 1 &&
37+
test_commit -C server my_commit2 1 &&
38+
git clone --depth=1 "file://$(pwd)/server" client &&
39+
git -C client fetch --unshallow --filter="blob:none" &&
40+
test_cmp_config -C client true remote.origin.promisor &&
41+
test_cmp_config -C client blob:none remote.origin.partialclonefilter &&
42+
test_cmp_config -C client 1 core.repositoryformatversion
43+
'
44+
3345
test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '
3446
rm -rf repo &&
3547
test_create_repo repo &&

t/t1090-sparse-checkout-scope.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ test_expect_success 'in partial clone, sparse checkout only fetches needed blobs
6363
git -C server commit -m message &&
6464
6565
test_config -C client core.sparsecheckout 1 &&
66-
test_config -C client extensions.partialclone origin &&
6766
echo "!/*" >client/.git/info/sparse-checkout &&
6867
echo "/a" >>client/.git/info/sparse-checkout &&
6968
git -C client fetch --filter=blob:none origin &&

t/t5500-fetch-pack.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,6 @@ fetch_filter_blob_limit_zero () {
999999
test_config -C "$SERVER" uploadpack.allowfilter 1 &&
10001000

10011001
git clone "$URL" client &&
1002-
test_config -C client extensions.partialclone origin &&
10031002

10041003
test_commit -C "$SERVER" two &&
10051004

t/t5702-protocol-v2.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ test_expect_success 'partial fetch' '
348348
rm -rf client "$(pwd)/trace" &&
349349
git init client &&
350350
SERVER="file://$(pwd)/server" &&
351-
test_config -C client extensions.partialClone "$SERVER" &&
352351
353352
GIT_TRACE_PACKET="$(pwd)/trace" git -C client -c protocol.version=2 \
354353
fetch --filter=blob:none "$SERVER" master:refs/heads/other &&

0 commit comments

Comments
 (0)