3 test_description
='previous branch syntax @{-n}'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 test_expect_success
'branch -d @{-1}' '
12 git checkout -b junk &&
14 test "$(git symbolic-ref HEAD)" = refs/heads/main &&
15 git branch -d @{-1} &&
16 test_must_fail git rev-parse --verify refs/heads/junk
19 test_expect_success
'branch -d @{-12} when there is not enough switches yet' '
20 git reflog expire --expire=now &&
21 git checkout -b junk2 &&
23 test "$(git symbolic-ref HEAD)" = refs/heads/main &&
24 test_must_fail git branch -d @{-12} &&
25 git rev-parse --verify refs/heads/main
28 test_expect_success
'merge @{-1}' '
34 git branch -f main B &&
35 git branch -f other &&
39 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
42 test_expect_success
'merge @{-1}~1' '
48 git cat-file commit HEAD >actual &&
49 grep "Merge branch '\''other'\''" actual
52 test_expect_success
'merge @{-100} before checking out that many branches yet' '
53 git reflog expire --expire=now &&
54 git checkout -f main &&
56 git branch -f other C &&
59 test_must_fail git merge @{-100}
62 test_expect_success
'log -g @{-1}' '
63 git checkout -b last_branch &&
64 git checkout -b new_branch &&
65 echo "last_branch@{0}" >expect &&
66 git log -g --format=%gd @{-1} >actual &&
67 test_cmp expect actual