Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 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 | |
Nguyễn Thái Ngọc Duy | 4db86e8 | 2013-01-21 20:00:48 +0700 | [diff] [blame] | 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 && |
Vasco Almeida | ab33a76 | 2016-06-17 20:21:06 +0000 | [diff] [blame] | 21 | test_i18ngrep ambiguous error |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 22 | ' |
| 23 | |
Nguyễn Thái Ngọc Duy | 4db86e8 | 2013-01-21 20:00:48 +0700 | [diff] [blame] | 24 | test_expect_success '"git log :/a -- " should not be ambiguous' ' |
| 25 | git log :/a -- |
| 26 | ' |
| 27 | |
| 28 | test_expect_success '"git log -- :/a" should not be ambiguous' ' |
| 29 | git log -- :/a |
| 30 | ' |
| 31 | |
Jeff King | be6ed3f | 2017-05-26 15:06:41 -0400 | [diff] [blame] | 32 | # This differs from the ":/a" check above in that :/in looks like a pathspec, |
| 33 | # but doesn't match an actual file. |
| 34 | test_expect_success '"git log :/in" should not be ambiguous' ' |
| 35 | git log :/in |
| 36 | ' |
| 37 | |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 38 | test_expect_success '"git log :" should be ambiguous' ' |
| 39 | test_must_fail git log : 2>error && |
Vasco Almeida | ab33a76 | 2016-06-17 20:21:06 +0000 | [diff] [blame] | 40 | test_i18ngrep ambiguous error |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 41 | ' |
| 42 | |
| 43 | test_expect_success 'git log -- :' ' |
| 44 | git log -- : |
| 45 | ' |
| 46 | |
| 47 | test_expect_success 'git log HEAD -- :/' ' |
| 48 | cat >expected <<-EOF && |
| 49 | 24b24cf initial |
| 50 | EOF |
| 51 | (cd sub && git log --oneline HEAD -- :/ >../actual) && |
| 52 | test_cmp expected actual |
| 53 | ' |
| 54 | |
Jeff King | 42471bc | 2017-05-26 15:08:39 -0400 | [diff] [blame] | 55 | test_expect_success '"git log :^sub" is not ambiguous' ' |
| 56 | git log :^sub |
| 57 | ' |
| 58 | |
| 59 | test_expect_success '"git log :^does-not-exist" does not match anything' ' |
| 60 | test_must_fail git log :^does-not-exist |
| 61 | ' |
| 62 | |
| 63 | test_expect_success '"git log :!" behaves the same as :^' ' |
| 64 | git log :!sub && |
| 65 | test_must_fail git log :!does-not-exist |
| 66 | ' |
| 67 | |
Jeff King | c99eddd | 2017-05-26 15:10:31 -0400 | [diff] [blame] | 68 | test_expect_success '"git log :(exclude)sub" is not ambiguous' ' |
| 69 | git log ":(exclude)sub" |
| 70 | ' |
| 71 | |
| 72 | test_expect_success '"git log :(exclude)sub --" must resolve as an object' ' |
| 73 | test_must_fail git log ":(exclude)sub" -- |
| 74 | ' |
| 75 | |
| 76 | test_expect_success '"git log :(unknown-magic) complains of bogus magic' ' |
| 77 | test_must_fail git log ":(unknown-magic)" 2>error && |
| 78 | test_i18ngrep pathspec.magic error |
| 79 | ' |
| 80 | |
Nguyễn Thái Ngọc Duy | c8556c6 | 2013-10-19 09:41:24 +0700 | [diff] [blame] | 81 | test_expect_success 'command line pathspec parsing for "git log"' ' |
| 82 | git reset --hard && |
| 83 | >a && |
| 84 | git add a && |
| 85 | git commit -m "add an empty a" --allow-empty && |
| 86 | echo 1 >a && |
| 87 | git commit -a -m "update a to 1" && |
| 88 | git checkout HEAD^ && |
| 89 | echo 2 >a && |
| 90 | git commit -a -m "update a to 2" && |
| 91 | test_must_fail git merge master && |
| 92 | git add a && |
| 93 | git log --merge -- a |
| 94 | ' |
| 95 | |
Brandon Williams | eef3df5 | 2017-12-04 16:07:34 -0800 | [diff] [blame] | 96 | test_expect_success 'tree_entry_interesting does not match past submodule boundaries' ' |
| 97 | test_when_finished "rm -rf repo submodule" && |
| 98 | git init submodule && |
| 99 | test_commit -C submodule initial && |
| 100 | git init repo && |
| 101 | >"repo/[bracket]" && |
| 102 | git -C repo add "[bracket]" && |
| 103 | test_tick && |
| 104 | git -C repo commit -m bracket && |
| 105 | git -C repo rev-list HEAD -- "[bracket]" >expect && |
| 106 | |
| 107 | git -C repo submodule add ../submodule && |
| 108 | test_tick && |
| 109 | git -C repo commit -m submodule && |
| 110 | |
| 111 | git -C repo rev-list HEAD -- "[bracket]" >actual && |
| 112 | test_cmp expect actual |
| 113 | ' |
| 114 | |
Nguyễn Thái Ngọc Duy | 6fd09f5 | 2011-05-08 18:08:26 +0700 | [diff] [blame] | 115 | test_done |