pathspec: make --literal-pathspecs disable pathspec magic
[git/git.git] / t / t6130-pathspec-noglob.sh
CommitLineData
823ab40f
JK
1#!/bin/sh
2
3test_description='test globbing (and noglob) of pathspec limiting'
4. ./test-lib.sh
5
6test_expect_success 'create commits with glob characters' '
7 test_commit unrelated bar &&
8 test_commit vanilla foo &&
6af95e8c
JS
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 &&
823ab40f
JK
16 test_commit bracket "f[o][o]"
17'
18
19test_expect_success 'vanilla pathspec matches literally' '
20 echo vanilla >expect &&
21 git log --format=%s -- foo >actual &&
22 test_cmp expect actual
23'
24
25test_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
35test_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
44test_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
5c6933d2
NTND
50test_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
823ab40f
JK
56test_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
5c6933d2
NTND
62test_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
823ab40f
JK
68test_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
5c6933d2
NTND
74test_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
a16bf9dd
NTND
80test_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
823ab40f
JK
86test_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
92test_done