]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0100-previous.sh
merge-ort: fix calling merge_finalize() with no intermediate merge
[thirdparty/git.git] / t / t0100-previous.sh
1 #!/bin/sh
2
3 test_description='previous branch syntax @{-n}'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
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
18 '
19
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
27 '
28
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'\''"
41 '
42
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
51 '
52
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}
61 '
62
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
69 '
70
71 test_done
72