Start the 2.46 cycle
[git.git] / t / t0100-previous.sh
blob70a3223f2199b06833166863e58489ba0f632e59
1 #!/bin/sh
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
9 . ./test-lib.sh
11 test_expect_success 'branch -d @{-1}' '
12 test_commit A &&
13 git checkout -b junk &&
14 git checkout - &&
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 &&
25 git checkout - &&
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}' '
34 git checkout A &&
35 test_commit B &&
36 git checkout A &&
37 test_commit C &&
38 test_commit D &&
39 git branch -f main B &&
40 git branch -f other &&
41 git checkout other &&
42 git checkout main &&
43 git merge @{-1} &&
44 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
47 test_expect_success 'merge @{-1}~1' '
48 git checkout main &&
49 git reset --hard B &&
50 git checkout other &&
51 git checkout main &&
52 git 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 &&
60 git reset --hard B &&
61 git branch -f other C &&
62 git checkout other &&
63 git checkout main &&
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
75 test_done