]>
Commit | Line | Data |
---|---|---|
6fd09f53 NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='magic pathspec tests using git-log' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | test_commit initial && | |
9 | test_tick && | |
10 | git commit --allow-empty -m empty && | |
11 | mkdir sub | |
12 | ' | |
13 | ||
4db86e8b NTND |
14 | test_expect_success '"git log :/" should not be ambiguous' ' |
15 | git log :/ | |
16 | ' | |
17 | ||
18 | test_expect_success '"git log :/a" should be ambiguous (applied both rev and worktree)' ' | |
19 | : >a && | |
20 | test_must_fail git log :/a 2>error && | |
ab33a76e | 21 | test_i18ngrep ambiguous error |
6fd09f53 NTND |
22 | ' |
23 | ||
4db86e8b NTND |
24 | test_expect_success '"git log :/a -- " should not be ambiguous' ' |
25 | git log :/a -- | |
26 | ' | |
27 | ||
6b3351e7 WC |
28 | test_expect_success '"git log :/detached -- " should find a commit only in HEAD' ' |
29 | test_when_finished "git checkout master" && | |
30 | git checkout --detach && | |
31 | # Must manually call `test_tick` instead of using `test_commit`, | |
32 | # because the latter additionally creates a tag, which would make | |
33 | # the commit reachable not only via HEAD. | |
34 | test_tick && | |
35 | git commit --allow-empty -m detached && | |
36 | test_tick && | |
37 | git commit --allow-empty -m something-else && | |
38 | git log :/detached -- | |
39 | ' | |
40 | ||
41 | test_expect_success '"git log :/detached -- " should not find an orphaned commit' ' | |
42 | test_must_fail git log :/detached -- | |
43 | ' | |
44 | ||
45 | test_expect_success '"git log :/detached -- " should find HEAD only of own worktree' ' | |
46 | git worktree add other-tree HEAD && | |
47 | git -C other-tree checkout --detach && | |
48 | test_tick && | |
49 | git -C other-tree commit --allow-empty -m other-detached && | |
50 | git -C other-tree log :/other-detached -- && | |
51 | test_must_fail git log :/other-detached -- | |
52 | ' | |
53 | ||
4db86e8b NTND |
54 | test_expect_success '"git log -- :/a" should not be ambiguous' ' |
55 | git log -- :/a | |
56 | ' | |
57 | ||
5ff4b920 JH |
58 | test_expect_success '"git log :/any/path/" should not segfault' ' |
59 | test_must_fail git log :/any/path/ | |
60 | ' | |
61 | ||
be6ed3f3 JK |
62 | # This differs from the ":/a" check above in that :/in looks like a pathspec, |
63 | # but doesn't match an actual file. | |
64 | test_expect_success '"git log :/in" should not be ambiguous' ' | |
65 | git log :/in | |
66 | ' | |
67 | ||
6fd09f53 NTND |
68 | test_expect_success '"git log :" should be ambiguous' ' |
69 | test_must_fail git log : 2>error && | |
ab33a76e | 70 | test_i18ngrep ambiguous error |
6fd09f53 NTND |
71 | ' |
72 | ||
73 | test_expect_success 'git log -- :' ' | |
74 | git log -- : | |
75 | ' | |
76 | ||
77 | test_expect_success 'git log HEAD -- :/' ' | |
0b2c4af4 | 78 | initial=$(git rev-parse --short HEAD^) && |
6fd09f53 | 79 | cat >expected <<-EOF && |
0b2c4af4 | 80 | $initial initial |
6fd09f53 NTND |
81 | EOF |
82 | (cd sub && git log --oneline HEAD -- :/ >../actual) && | |
83 | test_cmp expected actual | |
84 | ' | |
85 | ||
42471bce JK |
86 | test_expect_success '"git log :^sub" is not ambiguous' ' |
87 | git log :^sub | |
88 | ' | |
89 | ||
90 | test_expect_success '"git log :^does-not-exist" does not match anything' ' | |
91 | test_must_fail git log :^does-not-exist | |
92 | ' | |
93 | ||
94 | test_expect_success '"git log :!" behaves the same as :^' ' | |
95 | git log :!sub && | |
96 | test_must_fail git log :!does-not-exist | |
97 | ' | |
98 | ||
c99eddd8 JK |
99 | test_expect_success '"git log :(exclude)sub" is not ambiguous' ' |
100 | git log ":(exclude)sub" | |
101 | ' | |
102 | ||
103 | test_expect_success '"git log :(exclude)sub --" must resolve as an object' ' | |
104 | test_must_fail git log ":(exclude)sub" -- | |
105 | ' | |
106 | ||
107 | test_expect_success '"git log :(unknown-magic) complains of bogus magic' ' | |
108 | test_must_fail git log ":(unknown-magic)" 2>error && | |
109 | test_i18ngrep pathspec.magic error | |
110 | ' | |
111 | ||
c8556c62 NTND |
112 | test_expect_success 'command line pathspec parsing for "git log"' ' |
113 | git reset --hard && | |
114 | >a && | |
115 | git add a && | |
116 | git commit -m "add an empty a" --allow-empty && | |
117 | echo 1 >a && | |
118 | git commit -a -m "update a to 1" && | |
119 | git checkout HEAD^ && | |
120 | echo 2 >a && | |
121 | git commit -a -m "update a to 2" && | |
122 | test_must_fail git merge master && | |
123 | git add a && | |
124 | git log --merge -- a | |
125 | ' | |
126 | ||
eef3df5a BW |
127 | test_expect_success 'tree_entry_interesting does not match past submodule boundaries' ' |
128 | test_when_finished "rm -rf repo submodule" && | |
129 | git init submodule && | |
130 | test_commit -C submodule initial && | |
131 | git init repo && | |
132 | >"repo/[bracket]" && | |
133 | git -C repo add "[bracket]" && | |
134 | test_tick && | |
135 | git -C repo commit -m bracket && | |
136 | git -C repo rev-list HEAD -- "[bracket]" >expect && | |
137 | ||
138 | git -C repo submodule add ../submodule && | |
139 | test_tick && | |
140 | git -C repo commit -m submodule && | |
141 | ||
142 | git -C repo rev-list HEAD -- "[bracket]" >actual && | |
143 | test_cmp expect actual | |
144 | ' | |
145 | ||
6fd09f53 | 146 | test_done |