interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t0100-previous.sh

75 lines · 1809 bytes Raw Blame History
1#!/bin/sh
2
3test_description='previous branch syntax @{-n}'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8. ./test-lib.sh
9
10test_expect_success 'branch -d @{-1}' '
11 test_commit A &&
12 git checkout -b junk &&
13 git checkout - &&
14 echo refs/heads/main >expect &&
15 git symbolic-ref HEAD >actual &&
16 test_cmp expect actual &&
17 git branch -d @{-1} &&
18 test_must_fail git rev-parse --verify refs/heads/junk
19'
20
21test_expect_success 'branch -d @{-12} when there is not enough switches yet' '
22 git reflog expire --expire=now &&
23 git checkout -b junk2 &&
24 git checkout - &&
25 echo refs/heads/main >expect &&
26 git symbolic-ref HEAD >actual &&
27 test_cmp expect actual &&
28 test_must_fail git branch -d @{-12} &&
29 git rev-parse --verify refs/heads/main
30'
31
32test_expect_success 'merge @{-1}' '
33 git checkout A &&
34 test_commit B &&
35 git checkout A &&
36 test_commit C &&
37 test_commit D &&
38 git branch -f main B &&
39 git branch -f other &&
40 git checkout other &&
41 git checkout main &&
42 git merge @{-1} &&
43 git cat-file commit HEAD | grep "Merge branch '\''other'\''"
44'
45
46test_expect_success 'merge @{-1}~1' '
47 git checkout main &&
48 git reset --hard B &&
49 git checkout other &&
50 git checkout main &&
51 git merge @{-1}~1 &&
52 git cat-file commit HEAD >actual &&
53 test_grep "Merge branch '\''other'\''" actual
54'
55
56test_expect_success 'merge @{-100} before checking out that many branches yet' '
57 git reflog expire --expire=now &&
58 git checkout -f main &&
59 git reset --hard B &&
60 git branch -f other C &&
61 git checkout other &&
62 git checkout main &&
63 test_must_fail git merge @{-100}
64'
65
66test_expect_success 'log -g @{-1}' '
67 git checkout -b last_branch &&
68 git checkout -b new_branch &&
69 echo "last_branch@{0}" >expect &&
70 git log -g --format=%gd @{-1} >actual &&
71 test_cmp expect actual
72'
73
74test_done
75