3 test_description='test globbing (and noglob) of pathspec limiting'
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*" &&
16 test_commit bracket "f[o][o]"
19 test_expect_success 'vanilla pathspec matches literally' '
20 echo vanilla >expect &&
21 git log --format=%s -- foo >actual &&
22 test_cmp expect actual
25 test_expect_success 'star pathspec globs' '
26 cat >expect <<-\EOF &&
31 git log --format=%s -- "f*" >actual &&
32 test_cmp expect actual
35 test_expect_success 'star pathspec globs' '
36 cat >expect <<-\EOF &&
41 git log --format=%s -- ":(glob)f*" >actual &&
42 test_cmp expect actual
45 test_expect_success 'bracket pathspec globs and matches literal brackets' '
46 cat >expect <<-\EOF &&
50 git log --format=%s -- "f[o][o]" >actual &&
51 test_cmp expect actual
54 test_expect_success 'bracket pathspec globs and matches literal brackets' '
55 cat >expect <<-\EOF &&
59 git log --format=%s -- ":(glob)f[o][o]" >actual &&
60 test_cmp expect actual
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
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
75 test_expect_success 'no-glob option matches literally (star)' '
77 git --literal-pathspecs log --format=%s -- "f*" >actual &&
78 test_cmp expect actual
81 test_expect_success 'no-glob option matches literally (star)' '
83 git log --format=%s -- ":(literal)f*" >actual &&
84 test_cmp expect actual
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
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
99 test_expect_success 'no-glob option disables :(literal)' '
101 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
102 test_cmp expect actual
105 test_expect_success 'no-glob environment variable works' '
107 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
108 test_cmp expect actual
111 test_expect_success 'setup xxx/bar' '
113 test_commit xxx xxx/bar
116 test_expect_success '**/ works with :(glob)' '
117 cat >expect <<-\EOF &&
121 git log --format=%s -- ":(glob)**/bar" >actual &&
122 test_cmp expect actual
125 test_expect_success '**/ does not work with --noglob-pathspecs' '
127 git --noglob-pathspecs log --format=%s -- "**/bar" >actual &&
128 test_cmp expect actual
131 test_expect_success '**/ works with :(glob) and --noglob-pathspecs' '
132 cat >expect <<-\EOF &&
136 git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual &&
137 test_cmp expect actual
140 test_expect_success '**/ works with --glob-pathspecs' '
141 cat >expect <<-\EOF &&
145 git --glob-pathspecs log --format=%s -- "**/bar" >actual &&
146 test_cmp expect actual
149 test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' '
151 git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual &&
152 test_cmp expect actual