Merge branch 'bc/t3430-fixup'
[git.git] / t / t7521-ignored-mode.sh
blob91790943c3df0555c1dbaadc05a0832f4961f9bf
1 #!/bin/sh
3 test_description='git status ignored modes'
5 . ./test-lib.sh
7 test_expect_success 'setup initial commit and ignore file' '
8 cat >.gitignore <<-\EOF &&
9 *.ign
10 ignored_dir/
11 !*.unignore
12 EOF
13 git add . &&
14 git commit -m "Initial commit"
17 test_expect_success 'Verify behavior of status on directories with ignored files' '
18 test_when_finished "git clean -fdx" &&
19 cat >expect <<-\EOF &&
20 ? expect
21 ? output
22 ! dir/ignored/ignored_1.ign
23 ! dir/ignored/ignored_2.ign
24 ! ignored/ignored_1.ign
25 ! ignored/ignored_2.ign
26 EOF
28 mkdir -p ignored dir/ignored &&
29 touch ignored/ignored_1.ign ignored/ignored_2.ign \
30 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
32 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
33 test_i18ncmp expect output
36 test_expect_success 'Verify status behavior on directory with tracked & ignored files' '
37 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
38 cat >expect <<-\EOF &&
39 ? expect
40 ? output
41 ! dir/tracked_ignored/ignored_1.ign
42 ! dir/tracked_ignored/ignored_2.ign
43 ! tracked_ignored/ignored_1.ign
44 ! tracked_ignored/ignored_2.ign
45 EOF
47 mkdir -p tracked_ignored dir/tracked_ignored &&
48 touch tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
49 tracked_ignored/ignored_1.ign tracked_ignored/ignored_2.ign \
50 dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 \
51 dir/tracked_ignored/ignored_1.ign dir/tracked_ignored/ignored_2.ign &&
53 git add tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
54 dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 &&
55 git commit -m "commit tracked files" &&
57 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
58 test_i18ncmp expect output
61 test_expect_success 'Verify status behavior on directory with untracked and ignored files' '
62 test_when_finished "git clean -fdx" &&
63 cat >expect <<-\EOF &&
64 ? dir/untracked_ignored/untracked_1
65 ? dir/untracked_ignored/untracked_2
66 ? expect
67 ? output
68 ? untracked_ignored/untracked_1
69 ? untracked_ignored/untracked_2
70 ! dir/untracked_ignored/ignored_1.ign
71 ! dir/untracked_ignored/ignored_2.ign
72 ! untracked_ignored/ignored_1.ign
73 ! untracked_ignored/ignored_2.ign
74 EOF
76 mkdir -p untracked_ignored dir/untracked_ignored &&
77 touch untracked_ignored/untracked_1 untracked_ignored/untracked_2 \
78 untracked_ignored/ignored_1.ign untracked_ignored/ignored_2.ign \
79 dir/untracked_ignored/untracked_1 dir/untracked_ignored/untracked_2 \
80 dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign &&
82 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
83 test_i18ncmp expect output
86 test_expect_success 'Verify status matching ignored files on ignored directory' '
87 test_when_finished "git clean -fdx" &&
88 cat >expect <<-\EOF &&
89 ? expect
90 ? output
91 ! ignored_dir/
92 EOF
94 mkdir ignored_dir &&
95 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
96 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign &&
98 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
99 test_i18ncmp expect output
102 test_expect_success 'Verify status behavior on ignored directory containing tracked file' '
103 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
104 cat >expect <<-\EOF &&
105 ? expect
106 ? output
107 ! ignored_dir/ignored_1
108 ! ignored_dir/ignored_1.ign
109 ! ignored_dir/ignored_2
110 ! ignored_dir/ignored_2.ign
113 mkdir ignored_dir &&
114 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
115 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
116 ignored_dir/tracked &&
117 git add -f ignored_dir/tracked &&
118 git commit -m "Force add file in ignored directory" &&
119 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
120 test_i18ncmp expect output
123 test_expect_success 'Verify matching ignored files with --untracked-files=normal' '
124 test_when_finished "git clean -fdx" &&
125 cat >expect <<-\EOF &&
126 ? expect
127 ? output
128 ? untracked_dir/
129 ! ignored_dir/
130 ! ignored_files/ignored_1.ign
131 ! ignored_files/ignored_2.ign
134 mkdir ignored_dir ignored_files untracked_dir &&
135 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
136 ignored_files/ignored_1.ign ignored_files/ignored_2.ign \
137 untracked_dir/untracked &&
138 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
139 test_i18ncmp expect output
142 test_expect_success 'Verify matching ignored files with --untracked-files=normal' '
143 test_when_finished "git clean -fdx" &&
144 cat >expect <<-\EOF &&
145 ? expect
146 ? output
147 ? untracked_dir/
148 ! ignored_dir/
149 ! ignored_files/ignored_1.ign
150 ! ignored_files/ignored_2.ign
153 mkdir ignored_dir ignored_files untracked_dir &&
154 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
155 ignored_files/ignored_1.ign ignored_files/ignored_2.ign \
156 untracked_dir/untracked &&
157 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
158 test_i18ncmp expect output
161 test_expect_success 'Verify status behavior on ignored directory containing tracked file' '
162 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
163 cat >expect <<-\EOF &&
164 ? expect
165 ? output
166 ! ignored_dir/ignored_1
167 ! ignored_dir/ignored_1.ign
168 ! ignored_dir/ignored_2
169 ! ignored_dir/ignored_2.ign
172 mkdir ignored_dir &&
173 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
174 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
175 ignored_dir/tracked &&
176 git add -f ignored_dir/tracked &&
177 git commit -m "Force add file in ignored directory" &&
178 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
179 test_i18ncmp expect output
182 test_expect_success 'Verify behavior of status with --ignored=no' '
183 test_when_finished "git clean -fdx" &&
184 cat >expect <<-\EOF &&
185 ? expect
186 ? output
189 mkdir -p ignored dir/ignored &&
190 touch ignored/ignored_1.ign ignored/ignored_2.ign \
191 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
193 git status --porcelain=v2 --ignored=no --untracked-files=all >output &&
194 test_i18ncmp expect output
197 test_expect_success 'Verify behavior of status with --ignored=traditional and --untracked-files=all' '
198 test_when_finished "git clean -fdx" &&
199 cat >expect <<-\EOF &&
200 ? expect
201 ? output
202 ! dir/ignored/ignored_1.ign
203 ! dir/ignored/ignored_2.ign
204 ! ignored/ignored_1.ign
205 ! ignored/ignored_2.ign
208 mkdir -p ignored dir/ignored &&
209 touch ignored/ignored_1.ign ignored/ignored_2.ign \
210 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
212 git status --porcelain=v2 --ignored=traditional --untracked-files=all >output &&
213 test_i18ncmp expect output
216 test_expect_success 'Verify behavior of status with --ignored=traditional and --untracked-files=normal' '
217 test_when_finished "git clean -fdx" &&
218 cat >expect <<-\EOF &&
219 ? expect
220 ? output
221 ! dir/
222 ! ignored/
225 mkdir -p ignored dir/ignored &&
226 touch ignored/ignored_1.ign ignored/ignored_2.ign \
227 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
229 git status --porcelain=v2 --ignored=traditional --untracked-files=normal >output &&
230 test_i18ncmp expect output
233 test_done