Skip to content

Commit 011b775

Browse files
rcoupgitster
authored andcommitted
t5615-partial-clone: add test for fetch --refetch
Add a test for doing a refetch to apply a changed partial clone filter under protocol v0 and v2. Signed-off-by: Robert Coup <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c7bab0 commit 011b775

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

t/t5616-partial-clone.sh

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,56 @@ test_expect_success 'manual prefetch of missing objects' '
166166
test_line_count = 0 observed.oids
167167
'
168168

169+
# create new commits in "src" repo to establish a history on file.4.txt
170+
# and push to "srv.bare".
171+
test_expect_success 'push new commits to server for file.4.txt' '
172+
for x in a b c d e f
173+
do
174+
echo "Mod file.4.txt $x" >src/file.4.txt &&
175+
if list_contains "a,b" "$x"; then
176+
printf "%10000s" X >>src/file.4.txt
177+
fi &&
178+
if list_contains "c,d" "$x"; then
179+
printf "%20000s" X >>src/file.4.txt
180+
fi &&
181+
git -C src add file.4.txt &&
182+
git -C src commit -m "mod $x" || return 1
183+
done &&
184+
git -C src push -u srv main
185+
'
186+
187+
# Do partial fetch to fetch smaller files; then verify that without --refetch
188+
# applying a new filter does not refetch missing large objects. Then use
189+
# --refetch to apply the new filter on existing commits. Test it under both
190+
# protocol v2 & v0.
191+
test_expect_success 'apply a different filter using --refetch' '
192+
git -C pc1 fetch --filter=blob:limit=999 origin &&
193+
git -C pc1 rev-list --quiet --objects --missing=print \
194+
main..origin/main >observed &&
195+
test_line_count = 4 observed &&
196+
197+
git -C pc1 fetch --filter=blob:limit=19999 --refetch origin &&
198+
git -C pc1 rev-list --quiet --objects --missing=print \
199+
main..origin/main >observed &&
200+
test_line_count = 2 observed &&
201+
202+
git -c protocol.version=0 -C pc1 fetch --filter=blob:limit=29999 \
203+
--refetch origin &&
204+
git -C pc1 rev-list --quiet --objects --missing=print \
205+
main..origin/main >observed &&
206+
test_line_count = 0 observed
207+
'
208+
209+
test_expect_success 'fetch --refetch works with a shallow clone' '
210+
git clone --no-checkout --depth=1 --filter=blob:none "file://$(pwd)/srv.bare" pc1s &&
211+
git -C pc1s rev-list --objects --missing=print HEAD >observed &&
212+
test_line_count = 6 observed &&
213+
214+
GIT_TRACE=1 git -C pc1s fetch --filter=blob:limit=999 --refetch origin &&
215+
git -C pc1s rev-list --objects --missing=print HEAD >observed &&
216+
test_line_count = 6 observed
217+
'
218+
169219
test_expect_success 'partial clone with transfer.fsckobjects=1 works with submodules' '
170220
test_create_repo submodule &&
171221
test_commit -C submodule mycommit &&
@@ -225,7 +275,7 @@ test_expect_success 'use fsck before and after manually fetching a missing subtr
225275
226276
# Auto-fetch all remaining trees and blobs with --missing=error
227277
git -C dst rev-list --missing=error --objects main >fetched_objects &&
228-
test_line_count = 70 fetched_objects &&
278+
test_line_count = 88 fetched_objects &&
229279
230280
awk -f print_1.awk fetched_objects |
231281
xargs -n1 git -C dst cat-file -t >fetched_types &&

0 commit comments

Comments
 (0)