upload-pack: move {want,have}_obj to upload_pack_data
[git] / t / t7521-ignored-mode.sh
1 #!/bin/sh
2
3 test_description='git status ignored modes'
4
5 . ./test-lib.sh
6
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"
15 '
16
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
27
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 &&
31
32         git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
33         test_i18ncmp expect output
34 '
35
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
46
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 &&
52
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" &&
56
57         git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
58         test_i18ncmp expect output
59 '
60
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
75
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 &&
81
82         git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
83         test_i18ncmp expect output
84 '
85
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
93
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 &&
97
98         git status --porcelain=v2 --ignored=matching --untracked-files=all >output &&
99         test_i18ncmp expect output
100 '
101
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
111         EOF
112
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
121 '
122
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
132         EOF
133
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
140 '
141
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
151         EOF
152
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
159 '
160
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
170         EOF
171
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
180 '
181
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
187         EOF
188
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 &&
192
193         git status --porcelain=v2 --ignored=no --untracked-files=all >output &&
194         test_i18ncmp expect output
195 '
196
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
206         EOF
207
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 &&
211
212         git status --porcelain=v2 --ignored=traditional --untracked-files=all >output &&
213         test_i18ncmp expect output
214 '
215
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/
223         EOF
224
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 &&
228
229         git status --porcelain=v2 --ignored=traditional --untracked-files=normal >output &&
230         test_i18ncmp expect output
231 '
232
233 test_done