t/t0211-trace2-perf.sh: fix typo patern -> pattern
[alt-git.git] / t / t0100-previous.sh
bloba16cc3d298357be89e58514db83c1d3f04b3ad4d
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 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 &&
23 git checkout - &&
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}' '
30 git checkout A &&
31 test_commit B &&
32 git checkout A &&
33 test_commit C &&
34 test_commit D &&
35 git branch -f main B &&
36 git branch -f other &&
37 git checkout other &&
38 git checkout main &&
39 git merge @{-1} &&
40 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
43 test_expect_success 'merge @{-1}~1' '
44 git checkout main &&
45 git reset --hard B &&
46 git checkout other &&
47 git checkout main &&
48 git 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 &&
56 git reset --hard B &&
57 git branch -f other C &&
58 git checkout other &&
59 git checkout main &&
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
71 test_done