3 test_description
='previous branch syntax @{-n}'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'branch -d @{-1}' '
13 git checkout -b junk &&
15 test "$(git symbolic-ref HEAD)" = refs/heads/main &&
16 git branch -d @{-1} &&
17 test_must_fail git rev-parse --verify refs/heads/junk
20 test_expect_success
'branch -d @{-12} when there is not enough switches yet' '
21 git reflog expire --expire=now &&
22 git checkout -b junk2 &&
24 test "$(git symbolic-ref HEAD)" = refs/heads/main &&
25 test_must_fail git branch -d @{-12} &&
26 git rev-parse --verify refs/heads/main
29 test_expect_success
'merge @{-1}' '
35 git branch -f main B &&
36 git branch -f other &&
40 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
43 test_expect_success
'merge @{-1}~1' '
49 git cat-file commit HEAD >actual &&
50 grep "Merge branch '\''other'\''" actual
53 test_expect_success
'merge @{-100} before checking out that many branches yet' '
54 git reflog expire --expire=now &&
55 git checkout -f main &&
57 git branch -f other C &&
60 test_must_fail git merge @{-100}
63 test_expect_success
'log -g @{-1}' '
64 git checkout -b last_branch &&
65 git checkout -b new_branch &&
66 echo "last_branch@{0}" >expect &&
67 git log -g --format=%gd @{-1} >actual &&
68 test_cmp expect actual