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 'bracket pathspec globs and matches literal brackets' '
36 cat >expect <<-\EOF &&
40 git log --format=%s -- "f[o][o]" >actual &&
41 test_cmp expect actual
44 test_expect_success 'no-glob option matches literally (vanilla)' '
45 echo vanilla >expect &&
46 git --literal-pathspecs log --format=%s -- foo >actual &&
47 test_cmp expect actual
50 test_expect_success 'no-glob option matches literally (vanilla)' '
51 echo vanilla >expect &&
52 git log --format=%s -- ":(literal)foo" >actual &&
53 test_cmp expect actual
56 test_expect_success 'no-glob option matches literally (star)' '
58 git --literal-pathspecs log --format=%s -- "f*" >actual &&
59 test_cmp expect actual
62 test_expect_success 'no-glob option matches literally (star)' '
64 git log --format=%s -- ":(literal)f*" >actual &&
65 test_cmp expect actual
68 test_expect_success 'no-glob option matches literally (bracket)' '
69 echo bracket >expect &&
70 git --literal-pathspecs log --format=%s -- "f[o][o]" >actual &&
71 test_cmp expect actual
74 test_expect_success 'no-glob option matches literally (bracket)' '
75 echo bracket >expect &&
76 git log --format=%s -- ":(literal)f[o][o]" >actual &&
77 test_cmp expect actual
80 test_expect_success 'no-glob option disables :(literal)' '
82 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
83 test_cmp expect actual
86 test_expect_success 'no-glob environment variable works' '
88 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
89 test_cmp expect actual