]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1505-rev-parse-last.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t1505-rev-parse-last.sh
CommitLineData
d18ba221
TR
1#!/bin/sh
2
3test_description='test @{-N} syntax'
4
334afbc7
JS
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
d18ba221
TR
8. ./test-lib.sh
9
10
11make_commit () {
12 echo "$1" > "$1" &&
13 git add "$1" &&
14 git commit -m "$1"
15}
16
17
18test_expect_success 'setup' '
19
20 make_commit 1 &&
21 git branch side &&
22 make_commit 2 &&
23 make_commit 3 &&
24 git checkout side &&
25 make_commit 4 &&
26 git merge master &&
27 git checkout master
28
29'
30
31# 1 -- 2 -- 3 master
32# \ \
33# \ \
34# --- 4 --- 5 side
35#
36# and 'side' should be the last branch
37
d18ba221 38test_expect_success '@{-1} works' '
5d77298d 39 test_cmp_rev side @{-1}
d18ba221
TR
40'
41
42test_expect_success '@{-1}~2 works' '
5d77298d 43 test_cmp_rev side~2 @{-1}~2
d18ba221
TR
44'
45
46test_expect_success '@{-1}^2 works' '
5d77298d 47 test_cmp_rev side^2 @{-1}^2
d18ba221
TR
48'
49
aa9c55b6 50test_expect_success '@{-1}@{1} works' '
5d77298d 51 test_cmp_rev side@{1} @{-1}@{1}
d18ba221
TR
52'
53
54test_expect_success '@{-2} works' '
5d77298d 55 test_cmp_rev master @{-2}
d18ba221
TR
56'
57
58test_expect_success '@{-3} fails' '
59 test_must_fail git rev-parse @{-3}
60'
61
62test_done
63
64