3 test_description
='parallel-checkout basics
5 Ensure that parallel-checkout basically works on clone and checkout, spawning
6 the required number of workers and correctly populating both the index and the
12 .
"$TEST_DIRECTORY/lib-parallel-checkout.sh"
14 # Test parallel-checkout with a branch switch containing a variety of file
15 # creations, deletions, and modifications, involving different entry types.
16 # The branches B1 and B2 have the following paths:
22 # c/c (file) c (symlink)
23 # d (symlink) d/d (file)
25 # e/e (file) e (submodule)
26 # f (submodule) f/f (file)
28 # g (submodule) g (symlink)
29 # h (symlink) h (submodule)
31 # Additionally, the following paths are present on both branches, but with
35 # j (symlink) j (symlink)
36 # k (submodule) k (submodule)
38 # And the following paths are only present in one of the branches:
43 test_expect_success
'setup repo for checkout with various types of changes' '
69 git submodule add ../sub f &&
70 git submodule add ../sub g &&
75 git submodule add -b B1 ../sub k &&
83 git rm -rf :^.gitmodules :^k &&
89 git submodule add ../sub e &&
92 git submodule add ../sub h &&
96 git -C k checkout B2 &&
103 git checkout --recurse-submodules B1
107 for mode
in sequential parallel sequential-fallback
110 sequential
) workers
=1 threshold
=0 expected_workers
=0 ;;
111 parallel
) workers
=2 threshold
=0 expected_workers
=2 ;;
112 sequential-fallback
) workers
=2 threshold
=100 expected_workers
=0 ;;
115 test_expect_success
"$mode checkout" '
116 repo=various_$mode &&
117 cp -R various $repo &&
119 # The just copied files have more recent timestamps than their
120 # associated index entries. So refresh the cached timestamps
121 # to avoid an "entry not up-to-date" error from `git checkout`.
122 # We only have to do this for the submodules as `git checkout`
123 # will already refresh the superproject index before performing
124 # the up-to-date check.
126 git -C $repo submodule foreach "git update-index --refresh" &&
128 set_checkout_config $workers $threshold &&
129 test_checkout_workers $expected_workers \
130 git -C $repo checkout --recurse-submodules B2 &&
131 verify_checkout $repo
135 for mode
in parallel sequential-fallback
138 parallel
) workers
=2 threshold
=0 expected_workers
=2 ;;
139 sequential-fallback
) workers
=2 threshold
=100 expected_workers
=0 ;;
142 test_expect_success
"$mode checkout on clone" '
143 repo=various_${mode}_clone &&
144 set_checkout_config $workers $threshold &&
145 test_checkout_workers $expected_workers \
146 git clone --recurse-submodules --branch B2 various $repo &&
147 verify_checkout $repo
151 # Just to be paranoid, actually compare the working trees' contents directly.
152 test_expect_success
'compare the working trees' '
153 rm -rf various_*/.git &&
154 rm -rf various_*/*/.git &&
156 # We use `git diff` instead of `diff -r` because the latter would
157 # follow symlinks, and not all `diff` implementations support the
158 # `--no-dereference` option.
160 git diff --no-index various_sequential various_parallel &&
161 git diff --no-index various_sequential various_parallel_clone &&
162 git diff --no-index various_sequential various_sequential-fallback &&
163 git diff --no-index various_sequential various_sequential-fallback_clone
166 # Currently, each submodule is checked out in a separated child process, but
167 # these subprocesses must also be able to use parallel checkout workers to
168 # write the submodules' entries.
169 test_expect_success
'submodules can use parallel checkout' '
170 set_checkout_config 2 0 &&
175 test_commit -C sub A &&
176 test_commit -C sub B &&
177 git submodule add ./sub &&
180 test_checkout_workers 2 git checkout --recurse-submodules .
184 test_expect_success
'parallel checkout respects --[no]-force' '
185 set_checkout_config 2 0 &&
197 # We expect 0 workers because there is nothing to be done
198 test_checkout_workers 0 git checkout HEAD &&
199 test_path_is_file D &&
203 test_checkout_workers 2 git checkout --force HEAD &&
204 test_path_is_dir D &&
210 test_expect_success SYMLINKS
'parallel checkout checks for symlinks in leading dirs' '
211 set_checkout_config 2 0 &&
216 # Commit 2 files to have enough work for 2 parallel workers
222 test_checkout_workers 2 git checkout --force HEAD &&