3 test_description
='git status ignored modes'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup initial commit and ignore file' '
9 cat >.gitignore <<-\EOF &&
15 git commit -m "Initial commit"
18 test_expect_success
'Verify behavior of status on directories with ignored files' '
19 test_when_finished "git clean -fdx" &&
20 cat >expect <<-\EOF &&
23 ! dir/ignored/ignored_1.ign
24 ! dir/ignored/ignored_2.ign
25 ! ignored/ignored_1.ign
26 ! ignored/ignored_2.ign
29 mkdir -p ignored dir/ignored &&
30 touch ignored/ignored_1.ign ignored/ignored_2.ign \
31 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
33 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
34 test_cmp expect output
37 test_expect_success
'Verify status behavior on directory with tracked & ignored files' '
38 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
39 cat >expect <<-\EOF &&
42 ! dir/tracked_ignored/ignored_1.ign
43 ! dir/tracked_ignored/ignored_2.ign
44 ! tracked_ignored/ignored_1.ign
45 ! tracked_ignored/ignored_2.ign
48 mkdir -p tracked_ignored dir/tracked_ignored &&
49 touch tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
50 tracked_ignored/ignored_1.ign tracked_ignored/ignored_2.ign \
51 dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 \
52 dir/tracked_ignored/ignored_1.ign dir/tracked_ignored/ignored_2.ign &&
54 git add tracked_ignored/tracked_1 tracked_ignored/tracked_2 \
55 dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 &&
56 git commit -m "commit tracked files" &&
58 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
59 test_cmp expect output
62 test_expect_success
'Verify status behavior on directory with untracked and ignored files' '
63 test_when_finished "git clean -fdx" &&
64 cat >expect <<-\EOF &&
65 ? dir/untracked_ignored/untracked_1
66 ? dir/untracked_ignored/untracked_2
69 ? untracked_ignored/untracked_1
70 ? untracked_ignored/untracked_2
71 ! dir/untracked_ignored/ignored_1.ign
72 ! dir/untracked_ignored/ignored_2.ign
73 ! untracked_ignored/ignored_1.ign
74 ! untracked_ignored/ignored_2.ign
77 mkdir -p untracked_ignored dir/untracked_ignored &&
78 touch untracked_ignored/untracked_1 untracked_ignored/untracked_2 \
79 untracked_ignored/ignored_1.ign untracked_ignored/ignored_2.ign \
80 dir/untracked_ignored/untracked_1 dir/untracked_ignored/untracked_2 \
81 dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign &&
83 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
84 test_cmp expect output
87 test_expect_success
'Verify status matching ignored files on ignored directory' '
88 test_when_finished "git clean -fdx" &&
89 cat >expect <<-\EOF &&
96 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
97 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign &&
99 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
100 test_cmp expect output
103 test_expect_success
'Verify status behavior on ignored directory containing tracked file' '
104 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
105 cat >expect <<-\EOF &&
108 ! ignored_dir/ignored_1
109 ! ignored_dir/ignored_1.ign
110 ! ignored_dir/ignored_2
111 ! ignored_dir/ignored_2.ign
115 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
116 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
117 ignored_dir/tracked &&
118 git add -f ignored_dir/tracked &&
119 git commit -m "Force add file in ignored directory" &&
120 git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
121 test_cmp expect output
124 test_expect_success
'Verify matching ignored files with --untracked-files=normal' '
125 test_when_finished "git clean -fdx" &&
126 cat >expect <<-\EOF &&
131 ! ignored_files/ignored_1.ign
132 ! ignored_files/ignored_2.ign
135 mkdir ignored_dir ignored_files untracked_dir &&
136 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
137 ignored_files/ignored_1.ign ignored_files/ignored_2.ign \
138 untracked_dir/untracked &&
139 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
140 test_cmp expect output
143 test_expect_success
'Verify matching ignored files with --untracked-files=normal' '
144 test_when_finished "git clean -fdx" &&
145 cat >expect <<-\EOF &&
150 ! ignored_files/ignored_1.ign
151 ! ignored_files/ignored_2.ign
154 mkdir ignored_dir ignored_files untracked_dir &&
155 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
156 ignored_files/ignored_1.ign ignored_files/ignored_2.ign \
157 untracked_dir/untracked &&
158 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
159 test_cmp expect output
162 test_expect_success
'Verify status behavior on ignored directory containing tracked file' '
163 test_when_finished "git clean -fdx && git reset HEAD~1 --hard" &&
164 cat >expect <<-\EOF &&
167 ! ignored_dir/ignored_1
168 ! ignored_dir/ignored_1.ign
169 ! ignored_dir/ignored_2
170 ! ignored_dir/ignored_2.ign
174 touch ignored_dir/ignored_1 ignored_dir/ignored_2 \
175 ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \
176 ignored_dir/tracked &&
177 git add -f ignored_dir/tracked &&
178 git commit -m "Force add file in ignored directory" &&
179 git status --porcelain=v2 --ignored=matching --untracked-files=normal >output &&
180 test_cmp expect output
183 test_expect_success
'Verify behavior of status with --ignored=no' '
184 test_when_finished "git clean -fdx" &&
185 cat >expect <<-\EOF &&
190 mkdir -p ignored dir/ignored &&
191 touch ignored/ignored_1.ign ignored/ignored_2.ign \
192 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
194 git status --porcelain=v2 --ignored=no --untracked-files=all >output &&
195 test_cmp expect output
198 test_expect_success
'Verify behavior of status with --ignored=traditional and --untracked-files=all' '
199 test_when_finished "git clean -fdx" &&
200 cat >expect <<-\EOF &&
203 ! dir/ignored/ignored_1.ign
204 ! dir/ignored/ignored_2.ign
205 ! ignored/ignored_1.ign
206 ! ignored/ignored_2.ign
209 mkdir -p ignored dir/ignored &&
210 touch ignored/ignored_1.ign ignored/ignored_2.ign \
211 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
213 git status --porcelain=v2 --ignored=traditional --untracked-files=all >output &&
214 test_cmp expect output
217 test_expect_success
'Verify behavior of status with --ignored=traditional and --untracked-files=normal' '
218 test_when_finished "git clean -fdx" &&
219 cat >expect <<-\EOF &&
226 mkdir -p ignored dir/ignored &&
227 touch ignored/ignored_1.ign ignored/ignored_2.ign \
228 dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign &&
230 git status --porcelain=v2 --ignored=traditional --untracked-files=normal >output &&
231 test_cmp expect output