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 echo refs/heads/main >expect &&
16 git symbolic-ref HEAD >actual &&
17 test_cmp expect actual &&
18 git branch -d @{-1} &&
19 test_must_fail git rev-parse --verify refs/heads/junk
22 test_expect_success
'branch -d @{-12} when there is not enough switches yet' '
23 git reflog expire --expire=now &&
24 git checkout -b junk2 &&
26 echo refs/heads/main >expect &&
27 git symbolic-ref HEAD >actual &&
28 test_cmp expect actual &&
29 test_must_fail git branch -d @{-12} &&
30 git rev-parse --verify refs/heads/main
33 test_expect_success
'merge @{-1}' '
39 git branch -f main B &&
40 git branch -f other &&
44 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
47 test_expect_success
'merge @{-1}~1' '
53 git cat-file commit HEAD >actual &&
54 grep "Merge branch '\''other'\''" actual
57 test_expect_success
'merge @{-100} before checking out that many branches yet' '
58 git reflog expire --expire=now &&
59 git checkout -f main &&
61 git branch -f other C &&
64 test_must_fail git merge @{-100}
67 test_expect_success
'log -g @{-1}' '
68 git checkout -b last_branch &&
69 git checkout -b new_branch &&
70 echo "last_branch@{0}" >expect &&
71 git log -g --format=%gd @{-1} >actual &&
72 test_cmp expect actual