refs.c: make prune_ref use a transaction to delete the ref
[git/mingw.git] / t / t1508-at-combinations.sh
blob078e1195dfa1625796fdbbf1b054ebf8a1ba2621
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 elif test '$2' = 'ref'
13 then
14 git rev-parse --symbolic-full-name '$1' >actual
15 else
16 git cat-file -p '$1' >actual
17 fi &&
18 test_cmp expect actual
22 nonsense() {
23 test_expect_${2:-success} "$1 is nonsensical" "
24 test_must_fail git rev-parse --verify '$1'
28 fail() {
29 "$@" failure
32 test_expect_success 'setup' '
33 test_commit master-one &&
34 test_commit master-two &&
35 git checkout -b upstream-branch &&
36 test_commit upstream-one &&
37 test_commit upstream-two &&
38 git checkout -b @/at-test &&
39 git checkout -b @@/at-test &&
40 git checkout -b @at-test &&
41 git checkout -b old-branch &&
42 test_commit old-one &&
43 test_commit old-two &&
44 git checkout -b new-branch &&
45 test_commit new-one &&
46 test_commit new-two &&
47 git branch -u master old-branch &&
48 git branch -u upstream-branch new-branch
51 check HEAD ref refs/heads/new-branch
52 check "@{1}" commit new-one
53 check "HEAD@{1}" commit new-one
54 check "@{now}" commit new-two
55 check "HEAD@{now}" commit new-two
56 check "@{-1}" ref refs/heads/old-branch
57 check "@{-1}@{0}" commit old-two
58 check "@{-1}@{1}" commit old-one
59 check "@{u}" ref refs/heads/upstream-branch
60 check "HEAD@{u}" ref refs/heads/upstream-branch
61 check "@{u}@{1}" commit upstream-one
62 check "@{-1}@{u}" ref refs/heads/master
63 check "@{-1}@{u}@{1}" commit master-one
64 check "@" commit new-two
65 check "@@{u}" ref refs/heads/upstream-branch
66 check "@@/at-test" ref refs/heads/@@/at-test
67 check "@/at-test" ref refs/heads/@/at-test
68 check "@at-test" ref refs/heads/@at-test
69 nonsense "@{u}@{-1}"
70 nonsense "@{0}@{0}"
71 nonsense "@{1}@{u}"
72 nonsense "HEAD@{-1}"
73 nonsense "@{-1}@{-1}"
75 # @{N} versus HEAD@{N}
77 check "HEAD@{3}" commit old-two
78 nonsense "@{3}"
80 test_expect_success 'switch to old-branch' '
81 git checkout old-branch
84 check HEAD ref refs/heads/old-branch
85 check "HEAD@{1}" commit new-two
86 check "@{1}" commit old-one
88 test_expect_success 'create path with @' '
89 echo content >normal &&
90 echo content >fun@ny &&
91 git add normal fun@ny &&
92 git commit -m "funny path"
95 check "@:normal" blob content
96 check "@:fun@ny" blob content
98 test_done