pathspec: make --literal-pathspecs disable pathspec magic
[git/git.git] / t / t6130-pathspec-noglob.sh
1 #!/bin/sh
2
3 test_description='test globbing (and noglob) of pathspec limiting'
4 . ./test-lib.sh
5
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*" &&
14 test_tick &&
15 git commit -m star &&
16 test_commit bracket "f[o][o]"
17 '
18
19 test_expect_success 'vanilla pathspec matches literally' '
20 echo vanilla >expect &&
21 git log --format=%s -- foo >actual &&
22 test_cmp expect actual
23 '
24
25 test_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
35 test_expect_success 'bracket pathspec globs and matches literal brackets' '
36 cat >expect <<-\EOF &&
37 bracket
38 vanilla
39 EOF
40 git log --format=%s -- "f[o][o]" >actual &&
41 test_cmp expect actual
42 '
43
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
48 '
49
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
54 '
55
56 test_expect_success 'no-glob option matches literally (star)' '
57 echo star >expect &&
58 git --literal-pathspecs log --format=%s -- "f*" >actual &&
59 test_cmp expect actual
60 '
61
62 test_expect_success 'no-glob option matches literally (star)' '
63 echo star >expect &&
64 git log --format=%s -- ":(literal)f*" >actual &&
65 test_cmp expect actual
66 '
67
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
72 '
73
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
78 '
79
80 test_expect_success 'no-glob option disables :(literal)' '
81 : >expect &&
82 git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual &&
83 test_cmp expect actual
84 '
85
86 test_expect_success 'no-glob environment variable works' '
87 echo star >expect &&
88 GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
89 test_cmp expect actual
90 '
91
92 test_done