]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t2205-add-worktree-config.sh
3 test_description
='directory traversal respects user config
5 This test verifies the traversal of the directory tree when the traversal begins
6 outside the repository. Two instances for which this can occur are tested:
8 1) The user manually sets the worktree. For this instance, the test sets
9 the worktree two levels above the `.git` directory and checks whether we
10 are able to add to the index those files that are in either (1) the
11 manually configured worktree directory or (2) the standard worktree
12 location with respect to the `.git` directory (i.e. ensuring that the
13 encountered `.git` directory is not treated as belonging to a foreign
15 2) The user manually sets the `git_dir` while the working directory is
16 outside the repository. The test checks that files inside the
17 repository can be added to the index.
22 test_expect_success
'1a: setup--config worktree' '
26 test_create_repo repo &&
27 git --git-dir="repo/.git" config core.worktree "$(pwd)" &&
29 mkdir -p outside-tracked outside-untracked &&
30 mkdir -p repo/inside-tracked repo/inside-untracked &&
33 >outside-tracked/file &&
34 >outside-untracked/file &&
36 >repo/file-untracked &&
37 >repo/inside-tracked/file &&
38 >repo/inside-untracked/file &&
40 cat >expect-tracked-unsorted <<-EOF &&
42 ../outside-tracked/file
47 cat >expect-untracked-unsorted <<-EOF &&
49 ../outside-untracked/file
54 cat >expect-all-dir-unsorted <<-EOF &&
62 cat expect-tracked-unsorted expect-untracked-unsorted >expect-all-unsorted &&
64 cat >.gitignore <<-EOF
72 test_expect_success
'1b: pre-add all' '
75 local parent_dir="$(pwd)" &&
76 git -C repo ls-files -o --exclude-standard "$parent_dir" >actual-all-unsorted &&
77 sort actual-all-unsorted >actual-all &&
78 sort expect-all-unsorted >expect-all &&
79 test_cmp expect-all actual-all
83 test_expect_success
'1c: pre-add dir all' '
86 local parent_dir="$(pwd)" &&
87 git -C repo ls-files -o --directory --exclude-standard "$parent_dir" >actual-all-dir-unsorted &&
88 sort actual-all-dir-unsorted >actual-all &&
89 sort expect-all-dir-unsorted >expect-all &&
90 test_cmp expect-all actual-all
94 test_expect_success
'1d: post-add tracked' '
97 local parent_dir="$(pwd)" &&
100 git add file-tracked &&
101 git add inside-tracked &&
102 git add ../outside-tracked &&
103 git add "$parent_dir/file-tracked" &&
104 git ls-files "$parent_dir" >../actual-tracked-unsorted
106 sort actual-tracked-unsorted >actual-tracked &&
107 sort expect-tracked-unsorted >expect-tracked &&
108 test_cmp expect-tracked actual-tracked
112 test_expect_success
'1e: post-add untracked' '
115 local parent_dir="$(pwd)" &&
116 git -C repo ls-files -o --exclude-standard "$parent_dir" >actual-untracked-unsorted &&
117 sort actual-untracked-unsorted >actual-untracked &&
118 sort expect-untracked-unsorted >expect-untracked &&
119 test_cmp expect-untracked actual-untracked
123 test_expect_success
'2a: setup--set git-dir' '
127 test_create_repo repo &&
128 # create two foreign repositories that should remain untracked
129 test_create_repo repo-outside &&
130 test_create_repo repo/repo-inside &&
132 mkdir -p repo/inside-tracked repo/inside-untracked &&
133 >repo/file-tracked &&
134 >repo/file-untracked &&
135 >repo/inside-tracked/file &&
136 >repo/inside-untracked/file &&
137 >repo-outside/file &&
138 >repo/repo-inside/file &&
140 cat >expect-tracked-unsorted <<-EOF &&
142 repo/inside-tracked/file
145 cat >expect-untracked-unsorted <<-EOF &&
147 repo/inside-untracked/file
152 cat >expect-all-dir-unsorted <<-EOF &&
157 cat expect-tracked-unsorted expect-untracked-unsorted >expect-all-unsorted &&
159 cat >.gitignore <<-EOF
167 test_expect_success
'2b: pre-add all' '
170 git --git-dir=repo/.git ls-files -o --exclude-standard >actual-all-unsorted &&
171 sort actual-all-unsorted >actual-all &&
172 sort expect-all-unsorted >expect-all &&
173 test_cmp expect-all actual-all
177 test_expect_success
'2c: pre-add dir all' '
180 git --git-dir=repo/.git ls-files -o --directory --exclude-standard >actual-all-dir-unsorted &&
181 sort actual-all-dir-unsorted >actual-all &&
182 sort expect-all-dir-unsorted >expect-all &&
183 test_cmp expect-all actual-all
187 test_expect_success
'2d: post-add tracked' '
190 git --git-dir=repo/.git add repo/file-tracked &&
191 git --git-dir=repo/.git add repo/inside-tracked &&
192 git --git-dir=repo/.git ls-files >actual-tracked-unsorted &&
193 sort actual-tracked-unsorted >actual-tracked &&
194 sort expect-tracked-unsorted >expect-tracked &&
195 test_cmp expect-tracked actual-tracked
199 test_expect_success
'2e: post-add untracked' '
202 git --git-dir=repo/.git ls-files -o --exclude-standard >actual-untracked-unsorted &&
203 sort actual-untracked-unsorted >actual-untracked &&
204 sort expect-untracked-unsorted >expect-untracked &&
205 test_cmp expect-untracked actual-untracked
209 test_expect_success
'3a: setup--add repo dir' '
213 test_create_repo repo &&
215 mkdir -p repo/inside-tracked repo/inside-ignored &&
216 >repo/file-tracked &&
217 >repo/file-ignored &&
218 >repo/inside-tracked/file &&
219 >repo/inside-ignored/file &&
221 cat >.gitignore <<-EOF &&
228 cat >expect-tracked-unsorted <<-EOF &&
230 repo/inside-tracked/file
233 cat >expect-ignored-unsorted <<-EOF
237 actual-ignored-unsorted
238 expect-ignored-unsorted
239 expect-tracked-unsorted
244 test_expect_success
'3b: ignored' '
247 git --git-dir=repo/.git ls-files -io --directory --exclude-standard >actual-ignored-unsorted &&
248 sort actual-ignored-unsorted >actual-ignored &&
249 sort expect-ignored-unsorted >expect-ignored &&
250 test_cmp expect-ignored actual-ignored
254 test_expect_success
'3c: add repo' '
257 git --git-dir=repo/.git add repo &&
258 git --git-dir=repo/.git ls-files >actual-tracked-unsorted &&
259 sort actual-tracked-unsorted >actual-tracked &&
260 sort expect-tracked-unsorted >expect-tracked &&
261 test_cmp expect-tracked actual-tracked