aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-15 00:03:29 -0800
committerJunio C Hamano <gitster@pobox.com>2009-02-15 00:03:29 -0800
commit472e4744ad28dfa568a1a46e5268aa2babb7243b (patch)
tree4f10098f38d27bf77eef3a22e60e51c258ece7fb /t
parent48c9ab78f3c7a0cc51e8d17bb7e37a075996c223 (diff)
parentc9717ee97075bb333684fa2f63e9136c5f7d89bf (diff)
downloadgit-472e4744ad28dfa568a1a46e5268aa2babb7243b.tar.gz
git-472e4744ad28dfa568a1a46e5268aa2babb7243b.tar.xz
Merge branch 'jc/branch-previous'
* jc/branch-previous: Teach @{-1} to git merge Teach the "@{-1} syntax to "git branch"
Diffstat (limited to 't')
-rwxr-xr-xt/t0100-previous.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh
new file mode 100755
index 000000000..315b9b3f1
--- /dev/null
+++ b/t/t0100-previous.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+test_description='previous branch syntax @{-n}'
+
+. ./test-lib.sh
+
+test_expect_success 'branch -d @{-1}' '
+ test_commit A &&
+ git checkout -b junk &&
+ git checkout - &&
+ test "$(git symbolic-ref HEAD)" = refs/heads/master &&
+ git branch -d @{-1} &&
+ test_must_fail git rev-parse --verify refs/heads/junk
+'
+
+test_expect_success 'branch -d @{-12} when there is not enough switches yet' '
+ git reflog expire --expire=now &&
+ git checkout -b junk2 &&
+ git checkout - &&
+ test "$(git symbolic-ref HEAD)" = refs/heads/master &&
+ test_must_fail git branch -d @{-12} &&
+ git rev-parse --verify refs/heads/master
+'
+
+test_expect_success 'merge @{-1}' '
+ git checkout A &&
+ test_commit B &&
+ git checkout A &&
+ test_commit C &&
+ git branch -f master B &&
+ git branch -f other &&
+ git checkout other &&
+ git checkout master &&
+ git merge @{-1} &&
+ git cat-file commit HEAD | grep "Merge branch '\''other'\''"
+'
+
+test_expect_success 'merge @{-1} when there is not enough switches yet' '
+ git reflog expire --expire=now &&
+ git checkout -f master &&
+ git reset --hard B &&
+ git branch -f other C &&
+ git checkout other &&
+ git checkout master &&
+ test_must_fail git merge @{-12}
+'
+
+test_done
+