Merge branch 'ab/test-lib'
[git/debian.git] / t / t1511-rev-parse-caret.sh
blob6ecfed86bc0d6aa6390f09dd3a06976208d3f8cb
1 #!/bin/sh
3 test_description='tests for ref^{stuff}'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 echo blob >a-blob &&
12 git tag -a -m blob blob-tag $(git hash-object -w a-blob) &&
13 mkdir a-tree &&
14 echo moreblobs >a-tree/another-blob &&
15 git add . &&
16 TREE_SHA1=$(git write-tree) &&
17 git tag -a -m tree tree-tag "$TREE_SHA1" &&
18 git commit -m Initial &&
19 git tag -a -m commit commit-tag &&
20 git branch ref &&
21 git checkout main &&
22 echo modified >>a-blob &&
23 git add -u &&
24 git commit -m Modified &&
25 git branch modref &&
26 echo changed! >>a-blob &&
27 git add -u &&
28 git commit -m !Exp &&
29 git branch expref &&
30 echo changed >>a-blob &&
31 git add -u &&
32 git commit -m Changed &&
33 echo changed-again >>a-blob &&
34 git add -u &&
35 git commit -m Changed-again
38 test_expect_success 'ref^{non-existent}' '
39 test_must_fail git rev-parse ref^{non-existent}
42 test_expect_success 'ref^{}' '
43 git rev-parse ref >expected &&
44 git rev-parse ref^{} >actual &&
45 test_cmp expected actual &&
46 git rev-parse commit-tag^{} >actual &&
47 test_cmp expected actual
50 test_expect_success 'ref^{commit}' '
51 git rev-parse ref >expected &&
52 git rev-parse ref^{commit} >actual &&
53 test_cmp expected actual &&
54 git rev-parse commit-tag^{commit} >actual &&
55 test_cmp expected actual &&
56 test_must_fail git rev-parse tree-tag^{commit} &&
57 test_must_fail git rev-parse blob-tag^{commit}
60 test_expect_success 'ref^{tree}' '
61 echo $TREE_SHA1 >expected &&
62 git rev-parse ref^{tree} >actual &&
63 test_cmp expected actual &&
64 git rev-parse commit-tag^{tree} >actual &&
65 test_cmp expected actual &&
66 git rev-parse tree-tag^{tree} >actual &&
67 test_cmp expected actual &&
68 test_must_fail git rev-parse blob-tag^{tree}
71 test_expect_success 'ref^{tag}' '
72 test_must_fail git rev-parse HEAD^{tag} &&
73 git rev-parse commit-tag >expected &&
74 git rev-parse commit-tag^{tag} >actual &&
75 test_cmp expected actual
78 test_expect_success 'ref^{/.}' '
79 git rev-parse main >expected &&
80 git rev-parse main^{/.} >actual &&
81 test_cmp expected actual
84 test_expect_success 'ref^{/non-existent}' '
85 test_must_fail git rev-parse main^{/non-existent}
88 test_expect_success 'ref^{/Initial}' '
89 git rev-parse ref >expected &&
90 git rev-parse main^{/Initial} >actual &&
91 test_cmp expected actual
94 test_expect_success 'ref^{/!Exp}' '
95 test_must_fail git rev-parse main^{/!Exp}
98 test_expect_success 'ref^{/!}' '
99 test_must_fail git rev-parse main^{/!}
102 test_expect_success 'ref^{/!!Exp}' '
103 git rev-parse expref >expected &&
104 git rev-parse main^{/!!Exp} >actual &&
105 test_cmp expected actual
108 test_expect_success 'ref^{/!-}' '
109 test_must_fail git rev-parse main^{/!-}
112 test_expect_success 'ref^{/!-.}' '
113 test_must_fail git rev-parse main^{/!-.}
116 test_expect_success 'ref^{/!-non-existent}' '
117 git rev-parse main >expected &&
118 git rev-parse main^{/!-non-existent} >actual &&
119 test_cmp expected actual
122 test_expect_success 'ref^{/!-Changed}' '
123 git rev-parse expref >expected &&
124 git rev-parse main^{/!-Changed} >actual &&
125 test_cmp expected actual
128 test_expect_success 'ref^{/!-!Exp}' '
129 git rev-parse modref >expected &&
130 git rev-parse expref^{/!-!Exp} >actual &&
131 test_cmp expected actual
134 test_done