]>
Commit | Line | Data |
---|---|---|
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-lib.sh | |
9 | ||
10 | test_expect_success 'branch -d @{-1}' ' | |
11 | test_commit A && | |
12 | git checkout -b junk && | |
13 | git checkout - && | |
14 | test "$(git symbolic-ref HEAD)" = refs/heads/main && | |
15 | git branch -d @{-1} && | |
16 | test_must_fail git rev-parse --verify refs/heads/junk | |
17 | ' | |
18 | ||
19 | test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' | |
20 | git reflog expire --expire=now && | |
21 | git checkout -b junk2 && | |
22 | git checkout - && | |
23 | test "$(git symbolic-ref HEAD)" = refs/heads/main && | |
24 | test_must_fail git branch -d @{-12} && | |
25 | git rev-parse --verify refs/heads/main | |
26 | ' | |
27 | ||
28 | test_expect_success 'merge @{-1}' ' | |
29 | git checkout A && | |
30 | test_commit B && | |
31 | git checkout A && | |
32 | test_commit C && | |
33 | test_commit D && | |
34 | git branch -f main B && | |
35 | git branch -f other && | |
36 | git checkout other && | |
37 | git checkout main && | |
38 | git merge @{-1} && | |
39 | git cat-file commit HEAD | grep "Merge branch '\''other'\''" | |
40 | ' | |
41 | ||
42 | test_expect_success 'merge @{-1}~1' ' | |
43 | git checkout main && | |
44 | git reset --hard B && | |
45 | git checkout other && | |
46 | git checkout main && | |
47 | git merge @{-1}~1 && | |
48 | git cat-file commit HEAD >actual && | |
49 | grep "Merge branch '\''other'\''" actual | |
50 | ' | |
51 | ||
52 | test_expect_success 'merge @{-100} before checking out that many branches yet' ' | |
53 | git reflog expire --expire=now && | |
54 | git checkout -f main && | |
55 | git reset --hard B && | |
56 | git branch -f other C && | |
57 | git checkout other && | |
58 | git checkout main && | |
59 | test_must_fail git merge @{-100} | |
60 | ' | |
61 | ||
62 | test_expect_success 'log -g @{-1}' ' | |
63 | git checkout -b last_branch && | |
64 | git checkout -b new_branch && | |
65 | echo "last_branch@{0}" >expect && | |
66 | git log -g --format=%gd @{-1} >actual && | |
67 | test_cmp expect actual | |
68 | ' | |
69 | ||
70 | test_done | |
71 |