summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-11 20:31:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-11 20:31:23 (GMT)
commitbb1c8fbcc86b31a1e86a1f6cadcb82d67fab1dc0 (patch)
tree6f68b3eab895b3b5af84a47925f910d0c8b26a99 /t
parent96d339f1e345e4457c4409f29a84d13254489621 (diff)
parent1f27e7d56b65fdc232a5a2a4de2ee97ff5eb176b (diff)
downloadgit-bb1c8fbcc86b31a1e86a1f6cadcb82d67fab1dc0.zip
git-bb1c8fbcc86b31a1e86a1f6cadcb82d67fab1dc0.tar.gz
git-bb1c8fbcc86b31a1e86a1f6cadcb82d67fab1dc0.tar.bz2
Merge branch 'fc/at-head'
Instead of typing four capital letters "HEAD", you can say "@" instead. * fc/at-head: sha1_name: compare variable with constant, not constant with variable Add new @ shortcut for HEAD sha1_name: refactor reinterpret() sha1_name: check @{-N} errors sooner sha1_name: reorganize get_sha1_basic() sha1_name: don't waste cycles in the @-parsing loop sha1_name: remove unnecessary braces sha1_name: remove no-op tests: at-combinations: @{N} versus HEAD@{N} tests: at-combinations: increase coverage tests: at-combinations: improve nonsense() tests: at-combinations: check ref names directly tests: at-combinations: simplify setup
Diffstat (limited to 't')
-rwxr-xr-xt/t1508-at-combinations.sh68
1 files changed, 48 insertions, 20 deletions
diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh
index d5d6244..4db1613 100755
--- a/t/t1508-at-combinations.sh
+++ b/t/t1508-at-combinations.sh
@@ -4,17 +4,24 @@ test_description='test various @{X} syntax combinations together'
. ./test-lib.sh
check() {
-test_expect_${3:-success} "$1 = $2" "
- echo '$2' >expect &&
- git log -1 --format=%s '$1' >actual &&
- test_cmp expect actual
-"
+ test_expect_${4:-success} "$1 = $3" "
+ echo '$3' >expect &&
+ if test '$2' = 'commit'
+ then
+ git log -1 --format=%s '$1' >actual
+ else
+ git rev-parse --symbolic-full-name '$1' >actual
+ fi &&
+ test_cmp expect actual
+ "
}
+
nonsense() {
-test_expect_${2:-success} "$1 is nonsensical" "
- test_must_fail git log -1 '$1'
-"
+ test_expect_${2:-success} "$1 is nonsensical" "
+ test_must_fail git rev-parse --verify '$1'
+ "
}
+
fail() {
"$@" failure
}
@@ -31,21 +38,42 @@ test_expect_success 'setup' '
git checkout -b new-branch &&
test_commit new-one &&
test_commit new-two &&
- git config branch.old-branch.remote . &&
- git config branch.old-branch.merge refs/heads/master &&
- git config branch.new-branch.remote . &&
- git config branch.new-branch.merge refs/heads/upstream-branch
+ git branch -u master old-branch &&
+ git branch -u upstream-branch new-branch
'
-check HEAD new-two
-check "@{1}" new-one
-check "@{-1}" old-two
-check "@{-1}@{1}" old-one
-check "@{u}" upstream-two
-check "@{u}@{1}" upstream-one
-check "@{-1}@{u}" master-two
-check "@{-1}@{u}@{1}" master-one
+check HEAD ref refs/heads/new-branch
+check "@{1}" commit new-one
+check "HEAD@{1}" commit new-one
+check "@{now}" commit new-two
+check "HEAD@{now}" commit new-two
+check "@{-1}" ref refs/heads/old-branch
+check "@{-1}@{0}" commit old-two
+check "@{-1}@{1}" commit old-one
+check "@{u}" ref refs/heads/upstream-branch
+check "HEAD@{u}" ref refs/heads/upstream-branch
+check "@{u}@{1}" commit upstream-one
+check "@{-1}@{u}" ref refs/heads/master
+check "@{-1}@{u}@{1}" commit master-one
+check "@" commit new-two
+check "@@{u}" ref refs/heads/upstream-branch
nonsense "@{u}@{-1}"
+nonsense "@{0}@{0}"
nonsense "@{1}@{u}"
+nonsense "HEAD@{-1}"
+nonsense "@{-1}@{-1}"
+
+# @{N} versus HEAD@{N}
+
+check "HEAD@{3}" commit old-two
+nonsense "@{3}"
+
+test_expect_success 'switch to old-branch' '
+ git checkout old-branch
+'
+
+check HEAD ref refs/heads/old-branch
+check "HEAD@{1}" commit new-two
+check "@{1}" commit old-one
test_done