stash: add test for the create command line arguments
[alt-git.git] / t / t3007-ls-files-recurse-submodules.sh
bloba5426171d3ec652ffc02fc8279bc5802f57204a3
1 #!/bin/sh
3 test_description='Test ls-files recurse-submodules feature
5 This test verifies the recurse-submodules feature correctly lists files from
6 submodules.
9 . ./test-lib.sh
11 test_expect_success 'setup directory structure and submodules' '
12 echo a >a &&
13 mkdir b &&
14 echo b >b/b &&
15 git add a b &&
16 git commit -m "add a and b" &&
17 git init submodule &&
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 &&
27 .gitmodules
29 b/b
30 submodule/c
31 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 &&
39 .gitmodules
41 b/b
42 submodule/c
43 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 &&
51 .gitmodules
53 b/b
54 submodule/c
55 EOF
57 echo a >not_added &&
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 &&
66 .gitmodules
68 b/b
69 submodule/.gitmodules
70 submodule/c
71 submodule/subsub/d
72 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" &&
92 echo h >h.txt &&
93 mkdir sib &&
94 echo sib >sib/file &&
95 git add h.txt sib/file &&
96 git commit -m "add h and sib/file" &&
97 git init sub &&
98 echo sub >sub/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 &&
105 .gitmodules
108 h.txt
109 sib/file
110 sub/file
111 submodule/.gitmodules
112 submodule/c
113 submodule/f.TXT
114 submodule/g.txt
115 submodule/subsub/d
116 submodule/subsub/e.txt
119 git ls-files --recurse-submodules >actual &&
120 test_cmp expect actual &&
121 cat 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 &&
128 h.txt
129 submodule/g.txt
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 &&
139 h.txt
140 submodule/f.TXT
141 submodule/g.txt
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 &&
151 h.txt
152 submodule/f.TXT
153 submodule/g.txt
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 &&
162 sub/file
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 &&
179 sib/file
180 sub/file
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
210 test_done