]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1511-rev-parse-caret.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t1511-rev-parse-caret.sh
CommitLineData
32574b68
NTND
1#!/bin/sh
2
3test_description='tests for ref^{stuff}'
4
334afbc7
JS
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
32574b68
NTND
8. ./test-lib.sh
9
10test_expect_success 'setup' '
11 echo blob >a-blob &&
9fe281b3 12 git tag -a -m blob blob-tag $(git hash-object -w a-blob) &&
32574b68
NTND
13 mkdir a-tree &&
14 echo moreblobs >a-tree/another-blob &&
15 git add . &&
9fe281b3 16 TREE_SHA1=$(git write-tree) &&
32574b68
NTND
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 master &&
22 echo modified >>a-blob &&
23 git add -u &&
06b6b68f
WP
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 &&
0769854f
WP
32 git commit -m Changed &&
33 echo changed-again >>a-blob &&
34 git add -u &&
35 git commit -m Changed-again
32574b68
NTND
36'
37
38test_expect_success 'ref^{non-existent}' '
39 test_must_fail git rev-parse ref^{non-existent}
40'
41
42test_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
48'
49
50test_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}
58'
59
60test_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}
69'
70
75aa26d3
RH
71test_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
76'
77
32574b68
NTND
78test_expect_success 'ref^{/.}' '
79 git rev-parse master >expected &&
80 git rev-parse master^{/.} >actual &&
81 test_cmp expected actual
82'
83
84test_expect_success 'ref^{/non-existent}' '
85 test_must_fail git rev-parse master^{/non-existent}
86'
87
88test_expect_success 'ref^{/Initial}' '
89 git rev-parse ref >expected &&
90 git rev-parse master^{/Initial} >actual &&
91 test_cmp expected actual
92'
93
06b6b68f
WP
94test_expect_success 'ref^{/!Exp}' '
95 test_must_fail git rev-parse master^{/!Exp}
96'
97
98test_expect_success 'ref^{/!}' '
99 test_must_fail git rev-parse master^{/!}
100'
101
102test_expect_success 'ref^{/!!Exp}' '
103 git rev-parse expref >expected &&
104 git rev-parse master^{/!!Exp} >actual &&
105 test_cmp expected actual
106'
107
0769854f
WP
108test_expect_success 'ref^{/!-}' '
109 test_must_fail git rev-parse master^{/!-}
110'
111
112test_expect_success 'ref^{/!-.}' '
113 test_must_fail git rev-parse master^{/!-.}
114'
115
116test_expect_success 'ref^{/!-non-existent}' '
117 git rev-parse master >expected &&
118 git rev-parse master^{/!-non-existent} >actual &&
119 test_cmp expected actual
120'
121
122test_expect_success 'ref^{/!-Changed}' '
123 git rev-parse expref >expected &&
124 git rev-parse master^{/!-Changed} >actual &&
125 test_cmp expected actual
126'
127
128test_expect_success 'ref^{/!-!Exp}' '
129 git rev-parse modref >expected &&
130 git rev-parse expref^{/!-!Exp} >actual &&
131 test_cmp expected actual
132'
133
32574b68 134test_done