Merge branch 'pt/xdg-config-path' into next
[git/mjg.git] / t / t1511-rev-parse-caret.sh
blob15973f20945769fd7661cd4b203e96032495a60e
1 #!/bin/sh
3 test_description='tests for ref^{stuff}'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 echo blob >a-blob &&
9 git tag -a -m blob blob-tag `git hash-object -w a-blob` &&
10 mkdir a-tree &&
11 echo moreblobs >a-tree/another-blob &&
12 git add . &&
13 TREE_SHA1=`git write-tree` &&
14 git tag -a -m tree tree-tag "$TREE_SHA1" &&
15 git commit -m Initial &&
16 git tag -a -m commit commit-tag &&
17 git branch ref &&
18 git checkout master &&
19 echo modified >>a-blob &&
20 git add -u &&
21 git commit -m Modified
24 test_expect_success 'ref^{non-existent}' '
25 test_must_fail git rev-parse ref^{non-existent}
28 test_expect_success 'ref^{}' '
29 git rev-parse ref >expected &&
30 git rev-parse ref^{} >actual &&
31 test_cmp expected actual &&
32 git rev-parse commit-tag^{} >actual &&
33 test_cmp expected actual
36 test_expect_success 'ref^{commit}' '
37 git rev-parse ref >expected &&
38 git rev-parse ref^{commit} >actual &&
39 test_cmp expected actual &&
40 git rev-parse commit-tag^{commit} >actual &&
41 test_cmp expected actual &&
42 test_must_fail git rev-parse tree-tag^{commit} &&
43 test_must_fail git rev-parse blob-tag^{commit}
46 test_expect_success 'ref^{tree}' '
47 echo $TREE_SHA1 >expected &&
48 git rev-parse ref^{tree} >actual &&
49 test_cmp expected actual &&
50 git rev-parse commit-tag^{tree} >actual &&
51 test_cmp expected actual &&
52 git rev-parse tree-tag^{tree} >actual &&
53 test_cmp expected actual &&
54 test_must_fail git rev-parse blob-tag^{tree}
57 test_expect_success 'ref^{tag}' '
58 test_must_fail git rev-parse HEAD^{tag} &&
59 git rev-parse commit-tag >expected &&
60 git rev-parse commit-tag^{tag} >actual &&
61 test_cmp expected actual
64 test_expect_success 'ref^{/.}' '
65 git rev-parse master >expected &&
66 git rev-parse master^{/.} >actual &&
67 test_cmp expected actual
70 test_expect_success 'ref^{/non-existent}' '
71 test_must_fail git rev-parse master^{/non-existent}
74 test_expect_success 'ref^{/Initial}' '
75 git rev-parse ref >expected &&
76 git rev-parse master^{/Initial} >actual &&
77 test_cmp expected actual
80 test_done