]>
Commit | Line | Data |
---|---|---|
d18ba221 TR |
1 | #!/bin/sh |
2 | ||
3 | test_description='test @{-N} syntax' | |
4 | ||
06d53148 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
9081a421 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
d18ba221 TR |
9 | . ./test-lib.sh |
10 | ||
11 | ||
12 | make_commit () { | |
13 | echo "$1" > "$1" && | |
14 | git add "$1" && | |
15 | git commit -m "$1" | |
16 | } | |
17 | ||
18 | ||
19 | test_expect_success 'setup' ' | |
20 | ||
21 | make_commit 1 && | |
22 | git branch side && | |
23 | make_commit 2 && | |
24 | make_commit 3 && | |
25 | git checkout side && | |
26 | make_commit 4 && | |
06d53148 JS |
27 | git merge main && |
28 | git checkout main | |
d18ba221 TR |
29 | |
30 | ' | |
31 | ||
06d53148 | 32 | # 1 -- 2 -- 3 main |
d18ba221 TR |
33 | # \ \ |
34 | # \ \ | |
35 | # --- 4 --- 5 side | |
36 | # | |
37 | # and 'side' should be the last branch | |
38 | ||
d18ba221 | 39 | test_expect_success '@{-1} works' ' |
5d77298d | 40 | test_cmp_rev side @{-1} |
d18ba221 TR |
41 | ' |
42 | ||
43 | test_expect_success '@{-1}~2 works' ' | |
5d77298d | 44 | test_cmp_rev side~2 @{-1}~2 |
d18ba221 TR |
45 | ' |
46 | ||
47 | test_expect_success '@{-1}^2 works' ' | |
5d77298d | 48 | test_cmp_rev side^2 @{-1}^2 |
d18ba221 TR |
49 | ' |
50 | ||
aa9c55b6 | 51 | test_expect_success '@{-1}@{1} works' ' |
5d77298d | 52 | test_cmp_rev side@{1} @{-1}@{1} |
d18ba221 TR |
53 | ' |
54 | ||
55 | test_expect_success '@{-2} works' ' | |
06d53148 | 56 | test_cmp_rev main @{-2} |
d18ba221 TR |
57 | ' |
58 | ||
59 | test_expect_success '@{-3} fails' ' | |
60 | test_must_fail git rev-parse @{-3} | |
61 | ' | |
62 | ||
63 | test_done | |
64 | ||
65 |