]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6130-pathspec-noglob.sh
l10n: it.po: update the Italian translation for Git 2.24.0 round #2
[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)
13 git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
14 test_tick &&
15 git commit -m star &&
823ab40f
JK
16 test_commit bracket "f[o][o]"
17'
18
19test_expect_success 'vanilla pathspec matches literally' '
20 echo vanilla >expect &&
21 git log --format=%s -- foo >actual &&
22 test_cmp expect actual
23'
24
25test_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
bd30c2e4
NTND
35test_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
823ab40f
JK
45test_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
bd30c2e4
NTND
54test_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
823ab40f
JK
63test_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
5c6933d2
NTND
69test_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
823ab40f
JK
75test_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
5c6933d2
NTND
81test_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
823ab40f
JK
87test_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
5c6933d2
NTND
93test_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
a16bf9dd 99test_expect_success 'no-glob option disables :(literal)' '
a16bf9dd 100 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
1c5e94f4 101 test_must_be_empty actual
a16bf9dd
NTND
102'
103
823ab40f
JK
104test_expect_success 'no-glob environment variable works' '
105 echo star >expect &&
106 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
107 test_cmp expect actual
108'
4a2d5ae2
NTND
109
110test_expect_success 'blame takes global pathspec flags' '
111 git --literal-pathspecs blame -- foo &&
112 git --icase-pathspecs blame -- foo &&
113 git --glob-pathspecs blame -- foo &&
114 git --noglob-pathspecs blame -- foo
115'
823ab40f 116
bd30c2e4
NTND
117test_expect_success 'setup xxx/bar' '
118 mkdir xxx &&
119 test_commit xxx xxx/bar
120'
121
122test_expect_success '**/ works with :(glob)' '
123 cat >expect <<-\EOF &&
124 xxx
125 unrelated
126 EOF
127 git log --format=%s -- ":(glob)**/bar" >actual &&
128 test_cmp expect actual
129'
130
131test_expect_success '**/ does not work with --noglob-pathspecs' '
bd30c2e4 132 git --noglob-pathspecs log --format=%s -- "**/bar" >actual &&
1c5e94f4 133 test_must_be_empty actual
bd30c2e4
NTND
134'
135
136test_expect_success '**/ works with :(glob) and --noglob-pathspecs' '
137 cat >expect <<-\EOF &&
138 xxx
139 unrelated
140 EOF
141 git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual &&
142 test_cmp expect actual
143'
144
145test_expect_success '**/ works with --glob-pathspecs' '
146 cat >expect <<-\EOF &&
147 xxx
148 unrelated
149 EOF
150 git --glob-pathspecs log --format=%s -- "**/bar" >actual &&
151 test_cmp expect actual
152'
153
154test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' '
bd30c2e4 155 git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual &&
1c5e94f4 156 test_must_be_empty actual
bd30c2e4
NTND
157'
158
823ab40f 159test_done