Merge branch 'jk/ref-filter-colors-fix' into maint
[git/gitweb.git] / t / t6132-pathspec-exclude.sh
blobeb829fce97dc7067cbb502b9f5fd2b14c4e74e10
1 #!/bin/sh
3 test_description='test case exclude pathspec'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 for p in file sub/file sub/sub/file sub/file2 sub/sub/sub/file sub2/file; do
9 if echo $p | grep /; then
10 mkdir -p $(dirname $p)
11 fi &&
12 : >$p &&
13 git add $p &&
14 git commit -m $p
15 done &&
16 git log --oneline --format=%s >actual &&
17 cat <<EOF >expect &&
18 sub2/file
19 sub/sub/sub/file
20 sub/file2
21 sub/sub/file
22 sub/file
23 file
24 EOF
25 test_cmp expect actual
28 test_expect_success 'exclude only pathspec uses default implicit pathspec' '
29 git log --oneline --format=%s -- . ":(exclude)sub" >expect &&
30 git log --oneline --format=%s -- ":(exclude)sub" >actual &&
31 test_cmp expect actual
34 test_expect_success 't_e_i() exclude sub' '
35 git log --oneline --format=%s -- . ":(exclude)sub" >actual &&
36 cat <<EOF >expect &&
37 sub2/file
38 file
39 EOF
40 test_cmp expect actual
43 test_expect_success 't_e_i() exclude sub/sub/file' '
44 git log --oneline --format=%s -- . ":(exclude)sub/sub/file" >actual &&
45 cat <<EOF >expect &&
46 sub2/file
47 sub/sub/sub/file
48 sub/file2
49 sub/file
50 file
51 EOF
52 test_cmp expect actual
55 test_expect_success 't_e_i() exclude sub using mnemonic' '
56 git log --oneline --format=%s -- . ":!sub" >actual &&
57 cat <<EOF >expect &&
58 sub2/file
59 file
60 EOF
61 test_cmp expect actual
64 test_expect_success 't_e_i() exclude :(icase)SUB' '
65 git log --oneline --format=%s -- . ":(exclude,icase)SUB" >actual &&
66 cat <<EOF >expect &&
67 sub2/file
68 file
69 EOF
70 test_cmp expect actual
73 test_expect_success 't_e_i() exclude sub2 from sub' '
75 cd sub &&
76 git log --oneline --format=%s -- :/ ":/!sub2" >actual &&
77 cat <<EOF >expect &&
78 sub/sub/sub/file
79 sub/file2
80 sub/sub/file
81 sub/file
82 file
83 EOF
84 test_cmp expect actual
88 test_expect_success 't_e_i() exclude sub/*file' '
89 git log --oneline --format=%s -- . ":(exclude)sub/*file" >actual &&
90 cat <<EOF >expect &&
91 sub2/file
92 sub/file2
93 file
94 EOF
95 test_cmp expect actual
98 test_expect_success 't_e_i() exclude :(glob)sub/*/file' '
99 git log --oneline --format=%s -- . ":(exclude,glob)sub/*/file" >actual &&
100 cat <<EOF >expect &&
101 sub2/file
102 sub/sub/sub/file
103 sub/file2
104 sub/file
105 file
107 test_cmp expect actual
110 test_expect_success 'm_p_d() exclude sub' '
111 git ls-files -- . ":(exclude)sub" >actual &&
112 cat <<EOF >expect &&
113 file
114 sub2/file
116 test_cmp expect actual
119 test_expect_success 'm_p_d() exclude sub/sub/file' '
120 git ls-files -- . ":(exclude)sub/sub/file" >actual &&
121 cat <<EOF >expect &&
122 file
123 sub/file
124 sub/file2
125 sub/sub/sub/file
126 sub2/file
128 test_cmp expect actual
131 test_expect_success 'm_p_d() exclude sub using mnemonic' '
132 git ls-files -- . ":!sub" >actual &&
133 cat <<EOF >expect &&
134 file
135 sub2/file
137 test_cmp expect actual
140 test_expect_success 'm_p_d() exclude :(icase)SUB' '
141 git ls-files -- . ":(exclude,icase)SUB" >actual &&
142 cat <<EOF >expect &&
143 file
144 sub2/file
146 test_cmp expect actual
149 test_expect_success 'm_p_d() exclude sub2 from sub' '
151 cd sub &&
152 git ls-files -- :/ ":/!sub2" >actual &&
153 cat <<EOF >expect &&
154 ../file
155 file
156 file2
157 sub/file
158 sub/sub/file
160 test_cmp expect actual
164 test_expect_success 'm_p_d() exclude sub/*file' '
165 git ls-files -- . ":(exclude)sub/*file" >actual &&
166 cat <<EOF >expect &&
167 file
168 sub/file2
169 sub2/file
171 test_cmp expect actual
174 test_expect_success 'm_p_d() exclude :(glob)sub/*/file' '
175 git ls-files -- . ":(exclude,glob)sub/*/file" >actual &&
176 cat <<EOF >expect &&
177 file
178 sub/file
179 sub/file2
180 sub/sub/sub/file
181 sub2/file
183 test_cmp expect actual
186 test_expect_success 'multiple exclusions' '
187 git ls-files -- ":^*/file2" ":^sub2" >actual &&
188 cat <<-\EOF >expect &&
189 file
190 sub/file
191 sub/sub/file
192 sub/sub/sub/file
194 test_cmp expect actual
197 test_done