]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6130-pathspec-noglob.sh
Sync with 2.16.6
[thirdparty/git.git] / t / t6130-pathspec-noglob.sh
CommitLineData
823ab40f
JK
1#!/bin/sh
2
3test_description='test globbing (and noglob) of pathspec limiting'
4. ./test-lib.sh
5
6test_expect_success 'create commits with glob characters' '
7 test_commit unrelated bar &&
8 test_commit vanilla foo &&
6af95e8c
JS
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)
35edce20 13 git config core.protectNTFS false &&
6af95e8c
JS
14 git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
15 test_tick &&
16 git commit -m star &&
823ab40f
JK
17 test_commit bracket "f[o][o]"
18'
19
20test_expect_success 'vanilla pathspec matches literally' '
21 echo vanilla >expect &&
22 git log --format=%s -- foo >actual &&
23 test_cmp expect actual
24'
25
26test_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
bd30c2e4
NTND
36test_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
823ab40f
JK
46test_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
bd30c2e4
NTND
55test_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
823ab40f
JK
64test_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
5c6933d2
NTND
70test_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
823ab40f
JK
76test_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
5c6933d2
NTND
82test_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
823ab40f
JK
88test_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
5c6933d2
NTND
94test_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
a16bf9dd
NTND
100test_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
823ab40f
JK
106test_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'
4a2d5ae2
NTND
111
112test_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'
823ab40f 118
bd30c2e4
NTND
119test_expect_success 'setup xxx/bar' '
120 mkdir xxx &&
121 test_commit xxx xxx/bar
122'
123
124test_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
133test_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
139test_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
148test_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
157test_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
823ab40f 163test_done