Git 2.30.9
[git.git] / t / t6130-pathspec-noglob.sh
blobba7902c9cdcd0e6664f81b478b24596a4deb06dc
1 #!/bin/sh
3 test_description='test globbing (and noglob) of pathspec limiting'
4 . ./test-lib.sh
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]"
20 test_expect_success 'vanilla pathspec matches literally' '
21 echo vanilla >expect &&
22 git log --format=%s -- foo >actual &&
23 test_cmp expect actual
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
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
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
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
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
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
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
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
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
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
100 test_expect_success 'no-glob option disables :(literal)' '
101 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
102 test_must_be_empty actual
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
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
118 test_expect_success 'setup xxx/bar' '
119 mkdir xxx &&
120 test_commit xxx xxx/bar
123 test_expect_success '**/ works with :(glob)' '
124 cat >expect <<-\EOF &&
126 unrelated
128 git log --format=%s -- ":(glob)**/bar" >actual &&
129 test_cmp expect actual
132 test_expect_success '**/ does not work with --noglob-pathspecs' '
133 git --noglob-pathspecs log --format=%s -- "**/bar" >actual &&
134 test_must_be_empty actual
137 test_expect_success '**/ works with :(glob) and --noglob-pathspecs' '
138 cat >expect <<-\EOF &&
140 unrelated
142 git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual &&
143 test_cmp expect actual
146 test_expect_success '**/ works with --glob-pathspecs' '
147 cat >expect <<-\EOF &&
149 unrelated
151 git --glob-pathspecs log --format=%s -- "**/bar" >actual &&
152 test_cmp expect actual
155 test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' '
156 git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual &&
157 test_must_be_empty actual
160 test_done