3 test_description
='Test ls-files recurse-submodules feature
5 This test verifies the recurse-submodules feature correctly lists files from
11 test_expect_success
'setup directory structure and submodules' '
16 git commit -m "add a and b" &&
18 echo c >submodule/c &&
19 git -C submodule add c &&
20 git -C submodule commit -m "add c" &&
21 git submodule add ./submodule &&
22 git commit -m "added submodule"
25 test_expect_success
'ls-files correctly outputs files in submodule' '
26 cat >expect <<-\EOF &&
33 git ls-files --recurse-submodules >actual &&
34 test_cmp expect actual
37 test_expect_success
'ls-files correctly outputs files in submodule with -z' '
38 lf_to_nul >expect <<-\EOF &&
45 git ls-files --recurse-submodules -z >actual &&
46 test_cmp expect actual
49 test_expect_success
'ls-files does not output files not added to a repo' '
50 cat >expect <<-\EOF &&
58 echo b >b/not_added &&
59 echo c >submodule/not_added &&
60 git ls-files --recurse-submodules >actual &&
61 test_cmp expect actual
64 test_expect_success
'ls-files recurses more than 1 level' '
65 cat >expect <<-\EOF &&
74 git init submodule/subsub &&
75 echo d >submodule/subsub/d &&
76 git -C submodule/subsub add d &&
77 git -C submodule/subsub commit -m "add d" &&
78 git -C submodule submodule add ./subsub &&
79 git -C submodule commit -m "added subsub" &&
80 git ls-files --recurse-submodules >actual &&
81 test_cmp expect actual
84 test_expect_success
'--recurse-submodules and pathspecs setup' '
85 echo e >submodule/subsub/e.txt &&
86 git -C submodule/subsub add e.txt &&
87 git -C submodule/subsub commit -m "adding e.txt" &&
88 echo f >submodule/f.TXT &&
89 echo g >submodule/g.txt &&
90 git -C submodule add f.TXT g.txt &&
91 git -C submodule commit -m "add f and g" &&
95 git add h.txt sib/file &&
96 git commit -m "add h and sib/file" &&
99 git -C sub add file &&
100 git -C sub commit -m "add file" &&
101 git submodule add ./sub &&
102 git commit -m "added sub" &&
104 cat >expect <<-\EOF &&
111 submodule/.gitmodules
116 submodule/subsub/e.txt
119 git ls-files --recurse-submodules >actual &&
120 test_cmp expect actual &&
122 git ls-files --recurse-submodules "*" >actual &&
123 test_cmp expect actual
126 test_expect_success
'--recurse-submodules and pathspecs' '
127 cat >expect <<-\EOF &&
130 submodule/subsub/e.txt
133 git ls-files --recurse-submodules "*.txt" >actual &&
134 test_cmp expect actual
137 test_expect_success
'--recurse-submodules and pathspecs' '
138 cat >expect <<-\EOF &&
142 submodule/subsub/e.txt
145 git ls-files --recurse-submodules ":(icase)*.txt" >actual &&
146 test_cmp expect actual
149 test_expect_success
'--recurse-submodules and pathspecs' '
150 cat >expect <<-\EOF &&
156 git ls-files --recurse-submodules ":(icase)*.txt" ":(exclude)submodule/subsub/*" >actual &&
157 test_cmp expect actual
160 test_expect_success
'--recurse-submodules and pathspecs' '
161 cat >expect <<-\EOF &&
165 git ls-files --recurse-submodules "sub" >actual &&
166 test_cmp expect actual &&
167 git ls-files --recurse-submodules "sub/" >actual &&
168 test_cmp expect actual &&
169 git ls-files --recurse-submodules "sub/file" >actual &&
170 test_cmp expect actual &&
171 git ls-files --recurse-submodules "su*/file" >actual &&
172 test_cmp expect actual &&
173 git ls-files --recurse-submodules "su?/file" >actual &&
174 test_cmp expect actual
177 test_expect_success
'--recurse-submodules and pathspecs' '
178 cat >expect <<-\EOF &&
183 git ls-files --recurse-submodules "s??/file" >actual &&
184 test_cmp expect actual &&
185 git ls-files --recurse-submodules "s???file" >actual &&
186 test_cmp expect actual &&
187 git ls-files --recurse-submodules "s*file" >actual &&
188 test_cmp expect actual
191 test_expect_success
'--recurse-submodules does not support --error-unmatch' '
192 test_must_fail git ls-files --recurse-submodules --error-unmatch 2>actual &&
193 test_i18ngrep "does not support --error-unmatch" actual
196 test_incompatible_with_recurse_submodules
() {
197 test_expect_success
"--recurse-submodules and $1 are incompatible" "
198 test_must_fail git ls-files --recurse-submodules $1 2>actual &&
199 test_i18ngrep 'unsupported mode' actual
203 test_incompatible_with_recurse_submodules
--deleted
204 test_incompatible_with_recurse_submodules
--modified
205 test_incompatible_with_recurse_submodules
--others
206 test_incompatible_with_recurse_submodules
--stage
207 test_incompatible_with_recurse_submodules
--killed
208 test_incompatible_with_recurse_submodules
--unmerged