tests: at-combinations: simplify setup
[git.git] / t / t1508-at-combinations.sh
blob46e3f166a6cf86fee96f90342cc85b864715488e
1 #!/bin/sh
3 test_description='test various @{X} syntax combinations together'
4 . ./test-lib.sh
6 check() {
7 test_expect_${3:-success} "$1 = $2" "
8 echo '$2' >expect &&
9 git log -1 --format=%s '$1' >actual &&
10 test_cmp expect actual
13 nonsense() {
14 test_expect_${2:-success} "$1 is nonsensical" "
15 test_must_fail git log -1 '$1'
18 fail() {
19 "$@" failure
22 test_expect_success 'setup' '
23 test_commit master-one &&
24 test_commit master-two &&
25 git checkout -b upstream-branch &&
26 test_commit upstream-one &&
27 test_commit upstream-two &&
28 git checkout -b old-branch &&
29 test_commit old-one &&
30 test_commit old-two &&
31 git checkout -b new-branch &&
32 test_commit new-one &&
33 test_commit new-two &&
34 git branch -u master old-branch &&
35 git branch -u upstream-branch new-branch
38 check HEAD new-two
39 check "@{1}" new-one
40 check "@{-1}" old-two
41 check "@{-1}@{1}" old-one
42 check "@{u}" upstream-two
43 check "@{u}@{1}" upstream-one
44 check "@{-1}@{u}" master-two
45 check "@{-1}@{u}@{1}" master-one
46 nonsense "@{u}@{-1}"
47 nonsense "@{1}@{u}"
49 test_done