]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6130-pathspec-noglob.sh
Sync with 2.16.6
[thirdparty/git.git] / t / t6130-pathspec-noglob.sh
1 #!/bin/sh
2
3 test_description='test globbing (and noglob) of pathspec limiting'
4 . ./test-lib.sh
5
6 test_expect_success 'create commits with glob characters' '
7 test_commit unrelated bar &&
8 test_commit vanilla foo &&
9 # insert file "f*" in the commit, but in a way that avoids
10 # the name "f*" in the worktree, because it is not allowed
11 # on Windows (the tests below do not depend on the presence
12 # of the file in the worktree)
13 git config core.protectNTFS false &&
14 git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
15 test_tick &&
16 git commit -m star &&
17 test_commit bracket "f[o][o]"
18 '
19
20 test_expect_success 'vanilla pathspec matches literally' '
21 echo vanilla >expect &&
22 git log --format=%s -- foo >actual &&
23 test_cmp expect actual
24 '
25
26 test_expect_success 'star pathspec globs' '
27 cat >expect <<-\EOF &&
28 bracket
29 star
30 vanilla
31 EOF
32 git log --format=%s -- "f*" >actual &&
33 test_cmp expect actual
34 '
35
36 test_expect_success 'star pathspec globs' '
37 cat >expect <<-\EOF &&
38 bracket
39 star
40 vanilla
41 EOF
42 git log --format=%s -- ":(glob)f*" >actual &&
43 test_cmp expect actual
44 '
45
46 test_expect_success 'bracket pathspec globs and matches literal brackets' '
47 cat >expect <<-\EOF &&
48 bracket
49 vanilla
50 EOF
51 git log --format=%s -- "f[o][o]" >actual &&
52 test_cmp expect actual
53 '
54
55 test_expect_success 'bracket pathspec globs and matches literal brackets' '
56 cat >expect <<-\EOF &&
57 bracket
58 vanilla
59 EOF
60 git log --format=%s -- ":(glob)f[o][o]" >actual &&
61 test_cmp expect actual
62 '
63
64 test_expect_success 'no-glob option matches literally (vanilla)' '
65 echo vanilla >expect &&
66 git --literal-pathspecs log --format=%s -- foo >actual &&
67 test_cmp expect actual
68 '
69
70 test_expect_success 'no-glob option matches literally (vanilla)' '
71 echo vanilla >expect &&
72 git log --format=%s -- ":(literal)foo" >actual &&
73 test_cmp expect actual
74 '
75
76 test_expect_success 'no-glob option matches literally (star)' '
77 echo star >expect &&
78 git --literal-pathspecs log --format=%s -- "f*" >actual &&
79 test_cmp expect actual
80 '
81
82 test_expect_success 'no-glob option matches literally (star)' '
83 echo star >expect &&
84 git log --format=%s -- ":(literal)f*" >actual &&
85 test_cmp expect actual
86 '
87
88 test_expect_success 'no-glob option matches literally (bracket)' '
89 echo bracket >expect &&
90 git --literal-pathspecs log --format=%s -- "f[o][o]" >actual &&
91 test_cmp expect actual
92 '
93
94 test_expect_success 'no-glob option matches literally (bracket)' '
95 echo bracket >expect &&
96 git log --format=%s -- ":(literal)f[o][o]" >actual &&
97 test_cmp expect actual
98 '
99
100 test_expect_success 'no-glob option disables :(literal)' '
101 : >expect &&
102 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
103 test_cmp expect actual
104 '
105
106 test_expect_success 'no-glob environment variable works' '
107 echo star >expect &&
108 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
109 test_cmp expect actual
110 '
111
112 test_expect_success 'blame takes global pathspec flags' '
113 git --literal-pathspecs blame -- foo &&
114 git --icase-pathspecs blame -- foo &&
115 git --glob-pathspecs blame -- foo &&
116 git --noglob-pathspecs blame -- foo
117 '
118
119 test_expect_success 'setup xxx/bar' '
120 mkdir xxx &&
121 test_commit xxx xxx/bar
122 '
123
124 test_expect_success '**/ works with :(glob)' '
125 cat >expect <<-\EOF &&
126 xxx
127 unrelated
128 EOF
129 git log --format=%s -- ":(glob)**/bar" >actual &&
130 test_cmp expect actual
131 '
132
133 test_expect_success '**/ does not work with --noglob-pathspecs' '
134 : >expect &&
135 git --noglob-pathspecs log --format=%s -- "**/bar" >actual &&
136 test_cmp expect actual
137 '
138
139 test_expect_success '**/ works with :(glob) and --noglob-pathspecs' '
140 cat >expect <<-\EOF &&
141 xxx
142 unrelated
143 EOF
144 git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual &&
145 test_cmp expect actual
146 '
147
148 test_expect_success '**/ works with --glob-pathspecs' '
149 cat >expect <<-\EOF &&
150 xxx
151 unrelated
152 EOF
153 git --glob-pathspecs log --format=%s -- "**/bar" >actual &&
154 test_cmp expect actual
155 '
156
157 test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' '
158 : >expect &&
159 git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual &&
160 test_cmp expect actual
161 '
162
163 test_done