3 test_description
='sparse checkout scope tests'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 test_expect_success
'setup' '
15 git commit -m "initial commit"
18 test_expect_success
'create feature branch' '
19 git checkout -b feature &&
23 git commit -m "modification"
26 test_expect_success
'perform sparse checkout of main' '
27 git config --local --bool core.sparsecheckout true &&
28 echo "!/*" >.git/info/sparse-checkout &&
29 echo "/a" >>.git/info/sparse-checkout &&
30 echo "/c" >>.git/info/sparse-checkout &&
32 test_path_is_file a &&
33 test_path_is_missing b &&
37 test_expect_success
'merge feature branch into sparse checkout of main' '
39 test_path_is_file a &&
40 test_path_is_missing b &&
41 test_path_is_file c &&
42 test "$(cat c)" = "modified"
45 test_expect_success
'return to full checkout of main' '
46 git checkout feature &&
47 echo "/*" >.git/info/sparse-checkout &&
49 test_path_is_file a &&
50 test_path_is_file b &&
51 test_path_is_file c &&
52 test "$(cat b)" = "modified"
55 test_expect_success
'in partial clone, sparse checkout only fetches needed blobs' '
56 test_create_repo server &&
57 git clone "file://$(pwd)/server" client &&
59 test_config -C server uploadpack.allowfilter 1 &&
60 test_config -C server uploadpack.allowanysha1inwant 1 &&
64 echo ccc >server/c/c &&
65 git -C server add a b c/c &&
66 git -C server commit -m message &&
68 test_config -C client core.sparsecheckout 1 &&
69 echo "!/*" >client/.git/info/sparse-checkout &&
70 echo "/a" >>client/.git/info/sparse-checkout &&
71 git -C client fetch --filter=blob:none origin &&
72 git -C client checkout FETCH_HEAD &&
74 git -C client rev-list HEAD \
75 --quiet --objects --missing=print >unsorted_actual &&
78 git hash-object server/b &&
80 git hash-object server/c/c
82 sort unsorted_actual >actual &&
83 sort unsorted_expect >expect &&
84 test_cmp expect actual