]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t4208-log-magic-pathspec.sh
3 test_description
='magic pathspec tests using git-log'
7 test_expect_success
'setup' '
10 git commit --allow-empty -m empty &&
14 test_expect_success
'"git log :/" should not be ambiguous' '
18 test_expect_success
'"git log :/a" should be ambiguous (applied both rev and worktree)' '
20 test_must_fail git log :/a 2>error &&
21 test_i18ngrep ambiguous error
24 test_expect_success
'"git log :/a -- " should not be ambiguous' '
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.
35 git commit --allow-empty -m detached &&
37 git commit --allow-empty -m something-else &&
41 test_expect_success
'"git log :/detached -- " should not find an orphaned commit' '
42 test_must_fail git log :/detached --
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 &&
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 --
54 test_expect_success
'"git log -- :/a" should not be ambiguous' '
58 # This differs from the ":/a" check above in that :/in looks like a pathspec,
59 # but doesn't match an actual file.
60 test_expect_success
'"git log :/in" should not be ambiguous' '
64 test_expect_success
'"git log :" should be ambiguous' '
65 test_must_fail git log : 2>error &&
66 test_i18ngrep ambiguous error
69 test_expect_success
'git log -- :' '
73 test_expect_success
'git log HEAD -- :/' '
74 initial=$(git rev-parse --short HEAD^) &&
75 cat >expected <<-EOF &&
78 (cd sub && git log --oneline HEAD -- :/ >../actual) &&
79 test_cmp expected actual
82 test_expect_success
'"git log :^sub" is not ambiguous' '
86 test_expect_success
'"git log :^does-not-exist" does not match anything' '
87 test_must_fail git log :^does-not-exist
90 test_expect_success
'"git log :!" behaves the same as :^' '
92 test_must_fail git log :!does-not-exist
95 test_expect_success
'"git log :(exclude)sub" is not ambiguous' '
96 git log ":(exclude)sub"
99 test_expect_success
'"git log :(exclude)sub --" must resolve as an object' '
100 test_must_fail git log ":(exclude)sub" --
103 test_expect_success
'"git log :(unknown-magic) complains of bogus magic' '
104 test_must_fail git log ":(unknown-magic)" 2>error &&
105 test_i18ngrep pathspec.magic error
108 test_expect_success
'command line pathspec parsing for "git log"' '
112 git commit -m "add an empty a" --allow-empty &&
114 git commit -a -m "update a to 1" &&
115 git checkout HEAD^ &&
117 git commit -a -m "update a to 2" &&
118 test_must_fail git merge master &&
123 test_expect_success
'tree_entry_interesting does not match past submodule boundaries' '
124 test_when_finished "rm -rf repo submodule" &&
125 git init submodule &&
126 test_commit -C submodule initial &&
129 git -C repo add "[bracket]" &&
131 git -C repo commit -m bracket &&
132 git -C repo rev-list HEAD -- "[bracket]" >expect &&
134 git -C repo submodule add ../submodule &&
136 git -C repo commit -m submodule &&
138 git -C repo rev-list HEAD -- "[bracket]" >actual &&
139 test_cmp expect actual