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