Code

Merge branch 'jn/gitweb-unspecified-action' into maint-1.7.8
[git.git] / t / t1505-rev-parse-last.sh
1 #!/bin/sh
3 test_description='test @{-N} syntax'
5 . ./test-lib.sh
8 make_commit () {
9         echo "$1" > "$1" &&
10         git add "$1" &&
11         git commit -m "$1"
12 }
15 test_expect_success 'setup' '
17         make_commit 1 &&
18         git branch side &&
19         make_commit 2 &&
20         make_commit 3 &&
21         git checkout side &&
22         make_commit 4 &&
23         git merge master &&
24         git checkout master
26 '
28 # 1 -- 2 -- 3 master
29 #  \         \
30 #   \         \
31 #    --- 4 --- 5 side
32 #
33 # and 'side' should be the last branch
35 test_rev_equivalent () {
37         git rev-parse "$1" > expect &&
38         git rev-parse "$2" > output &&
39         test_cmp expect output
41 }
43 test_expect_success '@{-1} works' '
44         test_rev_equivalent side @{-1}
45 '
47 test_expect_success '@{-1}~2 works' '
48         test_rev_equivalent side~2 @{-1}~2
49 '
51 test_expect_success '@{-1}^2 works' '
52         test_rev_equivalent side^2 @{-1}^2
53 '
55 test_expect_success '@{-1}@{1} works' '
56         test_rev_equivalent side@{1} @{-1}@{1}
57 '
59 test_expect_success '@{-2} works' '
60         test_rev_equivalent master @{-2}
61 '
63 test_expect_success '@{-3} fails' '
64         test_must_fail git rev-parse @{-3}
65 '
67 test_done