Junio C Hamano | 8415d5c | 2009-02-13 23:08:05 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='previous branch syntax @{-n}' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'branch -d @{-1}' ' |
| 8 | test_commit A && |
| 9 | git checkout -b junk && |
| 10 | git checkout - && |
| 11 | test "$(git symbolic-ref HEAD)" = refs/heads/master && |
| 12 | git branch -d @{-1} && |
| 13 | test_must_fail git rev-parse --verify refs/heads/junk |
| 14 | ' |
| 15 | |
| 16 | test_expect_success 'branch -d @{-12} when there is not enough switches yet' ' |
| 17 | git reflog expire --expire=now && |
| 18 | git checkout -b junk2 && |
| 19 | git checkout - && |
| 20 | test "$(git symbolic-ref HEAD)" = refs/heads/master && |
| 21 | test_must_fail git branch -d @{-12} && |
| 22 | git rev-parse --verify refs/heads/master |
| 23 | ' |
| 24 | |
Junio C Hamano | c9717ee | 2009-02-13 23:26:12 -0800 | [diff] [blame] | 25 | test_expect_success 'merge @{-1}' ' |
| 26 | git checkout A && |
| 27 | test_commit B && |
| 28 | git checkout A && |
| 29 | test_commit C && |
Junio C Hamano | 84cf246 | 2013-05-15 14:32:30 -0700 | [diff] [blame] | 30 | test_commit D && |
Junio C Hamano | c9717ee | 2009-02-13 23:26:12 -0800 | [diff] [blame] | 31 | git branch -f master B && |
| 32 | git branch -f other && |
| 33 | git checkout other && |
| 34 | git checkout master && |
| 35 | git merge @{-1} && |
| 36 | git cat-file commit HEAD | grep "Merge branch '\''other'\''" |
| 37 | ' |
| 38 | |
Junio C Hamano | 84cf246 | 2013-05-15 14:32:30 -0700 | [diff] [blame] | 39 | test_expect_success 'merge @{-1}~1' ' |
| 40 | git checkout master && |
| 41 | git reset --hard B && |
| 42 | git checkout other && |
| 43 | git checkout master && |
| 44 | git merge @{-1}~1 && |
| 45 | git cat-file commit HEAD >actual && |
| 46 | grep "Merge branch '\''other'\''" actual |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'merge @{-100} before checking out that many branches yet' ' |
Junio C Hamano | c9717ee | 2009-02-13 23:26:12 -0800 | [diff] [blame] | 50 | git reflog expire --expire=now && |
| 51 | git checkout -f master && |
| 52 | git reset --hard B && |
| 53 | git branch -f other C && |
| 54 | git checkout other && |
| 55 | git checkout master && |
Junio C Hamano | 84cf246 | 2013-05-15 14:32:30 -0700 | [diff] [blame] | 56 | test_must_fail git merge @{-100} |
Junio C Hamano | c9717ee | 2009-02-13 23:26:12 -0800 | [diff] [blame] | 57 | ' |
| 58 | |
Junio C Hamano | 8415d5c | 2009-02-13 23:08:05 -0800 | [diff] [blame] | 59 | test_done |
| 60 | |