The 19th batch
[git.git] / t / t6130-pathspec-noglob.sh
blob82de25d549a07e0ada1ee858b6ccb6bf43107ce1
1 #!/bin/sh
3 test_description='test globbing (and noglob) of pathspec limiting'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'create commits with glob characters' '
9 test_commit unrelated bar &&
10 test_commit vanilla foo &&
11 # insert file "f*" in the commit, but in a way that avoids
12 # the name "f*" in the worktree, because it is not allowed
13 # on Windows (the tests below do not depend on the presence
14 # of the file in the worktree)
15 git config core.protectNTFS false &&
16 git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
17 test_tick &&
18 git commit -m star &&
19 test_commit bracket "f[o][o]"
22 test_expect_success 'vanilla pathspec matches literally' '
23 echo vanilla >expect &&
24 git log --format=%s -- foo >actual &&
25 test_cmp expect actual
28 test_expect_success 'star pathspec globs' '
29 cat >expect <<-\EOF &&
30 bracket
31 star
32 vanilla
33 EOF
34 git log --format=%s -- "f*" >actual &&
35 test_cmp expect actual
38 test_expect_success 'star pathspec globs' '
39 cat >expect <<-\EOF &&
40 bracket
41 star
42 vanilla
43 EOF
44 git log --format=%s -- ":(glob)f*" >actual &&
45 test_cmp expect actual
48 test_expect_success 'bracket pathspec globs and matches literal brackets' '
49 cat >expect <<-\EOF &&
50 bracket
51 vanilla
52 EOF
53 git log --format=%s -- "f[o][o]" >actual &&
54 test_cmp expect actual
57 test_expect_success 'bracket pathspec globs and matches literal brackets' '
58 cat >expect <<-\EOF &&
59 bracket
60 vanilla
61 EOF
62 git log --format=%s -- ":(glob)f[o][o]" >actual &&
63 test_cmp expect actual
66 test_expect_success 'no-glob option matches literally (vanilla)' '
67 echo vanilla >expect &&
68 git --literal-pathspecs log --format=%s -- foo >actual &&
69 test_cmp expect actual
72 test_expect_success 'no-glob option matches literally (vanilla)' '
73 echo vanilla >expect &&
74 git log --format=%s -- ":(literal)foo" >actual &&
75 test_cmp expect actual
78 test_expect_success 'no-glob option matches literally (star)' '
79 echo star >expect &&
80 git --literal-pathspecs log --format=%s -- "f*" >actual &&
81 test_cmp expect actual
84 test_expect_success 'no-glob option matches literally (star)' '
85 echo star >expect &&
86 git log --format=%s -- ":(literal)f*" >actual &&
87 test_cmp expect actual
90 test_expect_success 'no-glob option matches literally (bracket)' '
91 echo bracket >expect &&
92 git --literal-pathspecs log --format=%s -- "f[o][o]" >actual &&
93 test_cmp expect actual
96 test_expect_success 'no-glob option matches literally (bracket)' '
97 echo bracket >expect &&
98 git log --format=%s -- ":(literal)f[o][o]" >actual &&
99 test_cmp expect actual
102 test_expect_success 'no-glob option disables :(literal)' '
103 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
104 test_must_be_empty actual
107 test_expect_success 'no-glob environment variable works' '
108 echo star >expect &&
109 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
110 test_cmp expect actual
113 test_expect_success 'blame takes global pathspec flags' '
114 git --literal-pathspecs blame -- foo &&
115 git --icase-pathspecs blame -- foo &&
116 git --glob-pathspecs blame -- foo &&
117 git --noglob-pathspecs blame -- foo
120 test_expect_success 'setup xxx/bar' '
121 mkdir xxx &&
122 test_commit xxx xxx/bar
125 test_expect_success '**/ works with :(glob)' '
126 cat >expect <<-\EOF &&
128 unrelated
130 git log --format=%s -- ":(glob)**/bar" >actual &&
131 test_cmp expect actual
134 test_expect_success '**/ does not work with --noglob-pathspecs' '
135 git --noglob-pathspecs log --format=%s -- "**/bar" >actual &&
136 test_must_be_empty actual
139 test_expect_success '**/ works with :(glob) and --noglob-pathspecs' '
140 cat >expect <<-\EOF &&
142 unrelated
144 git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual &&
145 test_cmp expect actual
148 test_expect_success '**/ works with --glob-pathspecs' '
149 cat >expect <<-\EOF &&
151 unrelated
153 git --glob-pathspecs log --format=%s -- "**/bar" >actual &&
154 test_cmp expect actual
157 test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' '
158 git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual &&
159 test_must_be_empty actual
162 test_done