]>
Commit | Line | Data |
---|---|---|
7d782416 DT |
1 | #!/bin/sh |
2 | ||
3 | test_description='sparse checkout scope tests' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | echo "initial" >a && | |
9 | echo "initial" >b && | |
10 | echo "initial" >c && | |
11 | git add a b c && | |
12 | git commit -m "initial commit" | |
13 | ' | |
14 | ||
15 | test_expect_success 'create feature branch' ' | |
16 | git checkout -b feature && | |
17 | echo "modified" >b && | |
18 | echo "modified" >c && | |
19 | git add b c && | |
20 | git commit -m "modification" | |
21 | ' | |
22 | ||
23 | test_expect_success 'perform sparse checkout of master' ' | |
24 | git config --local --bool core.sparsecheckout true && | |
25 | echo "!/*" >.git/info/sparse-checkout && | |
26 | echo "/a" >>.git/info/sparse-checkout && | |
27 | echo "/c" >>.git/info/sparse-checkout && | |
28 | git checkout master && | |
29 | test_path_is_file a && | |
30 | test_path_is_missing b && | |
31 | test_path_is_file c | |
32 | ' | |
33 | ||
34 | test_expect_success 'merge feature branch into sparse checkout of master' ' | |
35 | git merge feature && | |
36 | test_path_is_file a && | |
37 | test_path_is_missing b && | |
38 | test_path_is_file c && | |
39 | test "$(cat c)" = "modified" | |
40 | ' | |
41 | ||
42 | test_expect_success 'return to full checkout of master' ' | |
43 | git checkout feature && | |
44 | echo "/*" >.git/info/sparse-checkout && | |
45 | git checkout master && | |
46 | test_path_is_file a && | |
47 | test_path_is_file b && | |
48 | test_path_is_file c && | |
49 | test "$(cat b)" = "modified" | |
50 | ' | |
51 | ||
2f215ff1 JT |
52 | test_expect_success 'in partial clone, sparse checkout only fetches needed blobs' ' |
53 | test_create_repo server && | |
54 | git clone "file://$(pwd)/server" client && | |
55 | ||
56 | test_config -C server uploadpack.allowfilter 1 && | |
57 | test_config -C server uploadpack.allowanysha1inwant 1 && | |
58 | echo a >server/a && | |
59 | echo bb >server/b && | |
60 | mkdir server/c && | |
61 | echo ccc >server/c/c && | |
62 | git -C server add a b c/c && | |
63 | git -C server commit -m message && | |
64 | ||
65 | test_config -C client core.sparsecheckout 1 && | |
2f215ff1 JT |
66 | echo "!/*" >client/.git/info/sparse-checkout && |
67 | echo "/a" >>client/.git/info/sparse-checkout && | |
68 | git -C client fetch --filter=blob:none origin && | |
69 | git -C client checkout FETCH_HEAD && | |
70 | ||
71 | git -C client rev-list HEAD \ | |
72 | --quiet --objects --missing=print >unsorted_actual && | |
73 | ( | |
74 | printf "?" && | |
75 | git hash-object server/b && | |
76 | printf "?" && | |
77 | git hash-object server/c/c | |
78 | ) >unsorted_expect && | |
79 | sort unsorted_actual >actual && | |
80 | sort unsorted_expect >expect && | |
81 | test_cmp expect actual | |
82 | ' | |
83 | ||
7d782416 | 84 | test_done |