diff: move no-index detection to builtin/diff.c
[git/mingw/j6t.git] / t / t1508-at-combinations.sh
blobceb844985f97e9472ffcc3fe2f375912d126a4e8
1 #!/bin/sh
3 test_description='test various @{X} syntax combinations together'
4 . ./test-lib.sh
6 check() {
7 test_expect_${4:-success} "$1 = $3" "
8 echo '$3' >expect &&
9 if test '$2' = 'commit'
10 then
11 git log -1 --format=%s '$1' >actual
12 else
13 git rev-parse --symbolic-full-name '$1' >actual
14 fi &&
15 test_cmp expect actual
19 nonsense() {
20 test_expect_${2:-success} "$1 is nonsensical" "
21 test_must_fail git rev-parse --verify '$1'
25 fail() {
26 "$@" failure
29 test_expect_success 'setup' '
30 test_commit master-one &&
31 test_commit master-two &&
32 git checkout -b upstream-branch &&
33 test_commit upstream-one &&
34 test_commit upstream-two &&
35 git checkout -b @/at-test &&
36 git checkout -b @@/at-test &&
37 git checkout -b @at-test &&
38 git checkout -b old-branch &&
39 test_commit old-one &&
40 test_commit old-two &&
41 git checkout -b new-branch &&
42 test_commit new-one &&
43 test_commit new-two &&
44 git branch -u master old-branch &&
45 git branch -u upstream-branch new-branch
48 check HEAD ref refs/heads/new-branch
49 check "@{1}" commit new-one
50 check "HEAD@{1}" commit new-one
51 check "@{now}" commit new-two
52 check "HEAD@{now}" commit new-two
53 check "@{-1}" ref refs/heads/old-branch
54 check "@{-1}@{0}" commit old-two
55 check "@{-1}@{1}" commit old-one
56 check "@{u}" ref refs/heads/upstream-branch
57 check "HEAD@{u}" ref refs/heads/upstream-branch
58 check "@{u}@{1}" commit upstream-one
59 check "@{-1}@{u}" ref refs/heads/master
60 check "@{-1}@{u}@{1}" commit master-one
61 check "@" commit new-two
62 check "@@{u}" ref refs/heads/upstream-branch
63 check "@@/at-test" ref refs/heads/@@/at-test
64 check "@/at-test" ref refs/heads/@/at-test
65 check "@at-test" ref refs/heads/@at-test
66 nonsense "@{u}@{-1}"
67 nonsense "@{0}@{0}"
68 nonsense "@{1}@{u}"
69 nonsense "HEAD@{-1}"
70 nonsense "@{-1}@{-1}"
72 # @{N} versus HEAD@{N}
74 check "HEAD@{3}" commit old-two
75 nonsense "@{3}"
77 test_expect_success 'switch to old-branch' '
78 git checkout old-branch
81 check HEAD ref refs/heads/old-branch
82 check "HEAD@{1}" commit new-two
83 check "@{1}" commit old-one
85 test_done