]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0100-previous.sh
The twentieth batch
[thirdparty/git.git] / t / t0100-previous.sh
CommitLineData
8415d5c7
JH
1#!/bin/sh
2
3test_description='previous branch syntax @{-n}'
4
06d53148 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
81ffbf83 8TEST_PASSES_SANITIZE_LEAK=true
8415d5c7
JH
9. ./test-lib.sh
10
11test_expect_success 'branch -d @{-1}' '
12 test_commit A &&
13 git checkout -b junk &&
14 git checkout - &&
4bd0785d
ÆAB
15 echo refs/heads/main >expect &&
16 git symbolic-ref HEAD >actual &&
17 test_cmp expect actual &&
8415d5c7
JH
18 git branch -d @{-1} &&
19 test_must_fail git rev-parse --verify refs/heads/junk
20'
21
22test_expect_success 'branch -d @{-12} when there is not enough switches yet' '
23 git reflog expire --expire=now &&
24 git checkout -b junk2 &&
25 git checkout - &&
4bd0785d
ÆAB
26 echo refs/heads/main >expect &&
27 git symbolic-ref HEAD >actual &&
28 test_cmp expect actual &&
8415d5c7 29 test_must_fail git branch -d @{-12} &&
06d53148 30 git rev-parse --verify refs/heads/main
8415d5c7
JH
31'
32
c9717ee9
JH
33test_expect_success 'merge @{-1}' '
34 git checkout A &&
35 test_commit B &&
36 git checkout A &&
37 test_commit C &&
84cf2466 38 test_commit D &&
06d53148 39 git branch -f main B &&
c9717ee9
JH
40 git branch -f other &&
41 git checkout other &&
06d53148 42 git checkout main &&
c9717ee9
JH
43 git merge @{-1} &&
44 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
45'
46
84cf2466 47test_expect_success 'merge @{-1}~1' '
06d53148 48 git checkout main &&
84cf2466
JH
49 git reset --hard B &&
50 git checkout other &&
06d53148 51 git checkout main &&
84cf2466
JH
52 git merge @{-1}~1 &&
53 git cat-file commit HEAD >actual &&
54 grep "Merge branch '\''other'\''" actual
55'
56
57test_expect_success 'merge @{-100} before checking out that many branches yet' '
c9717ee9 58 git reflog expire --expire=now &&
06d53148 59 git checkout -f main &&
c9717ee9
JH
60 git reset --hard B &&
61 git branch -f other C &&
62 git checkout other &&
06d53148 63 git checkout main &&
84cf2466 64 test_must_fail git merge @{-100}
c9717ee9
JH
65'
66
13228c30
JK
67test_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
73'
74
8415d5c7
JH
75test_done
76