Merge branch 'bc/more-git-var'
[alt-git.git] / t / t1505-rev-parse-last.sh
blob4a5758f08a8b2f38bc98e6ac4e26cfa36713780d
1 #!/bin/sh
3 test_description='test @{-N} syntax'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
12 make_commit () {
13 echo "$1" > "$1" &&
14 git add "$1" &&
15 git commit -m "$1"
19 test_expect_success 'setup' '
21 make_commit 1 &&
22 git branch side &&
23 make_commit 2 &&
24 make_commit 3 &&
25 git checkout side &&
26 make_commit 4 &&
27 git merge main &&
28 git checkout main
32 # 1 -- 2 -- 3 main
33 # \ \
34 # \ \
35 # --- 4 --- 5 side
37 # and 'side' should be the last branch
39 test_expect_success '@{-1} works' '
40 test_cmp_rev side @{-1}
43 test_expect_success '@{-1}~2 works' '
44 test_cmp_rev side~2 @{-1}~2
47 test_expect_success '@{-1}^2 works' '
48 test_cmp_rev side^2 @{-1}^2
51 test_expect_success '@{-1}@{1} works' '
52 test_cmp_rev side@{1} @{-1}@{1}
55 test_expect_success '@{-2} works' '
56 test_cmp_rev main @{-2}
59 test_expect_success '@{-3} fails' '
60 test_must_fail git rev-parse @{-3}
63 test_done