]>
Commit | Line | Data |
---|---|---|
32574b68 NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='tests for ref^{stuff}' | |
4 | ||
06d53148 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
32574b68 NTND |
8 | . ./test-lib.sh |
9 | ||
10 | test_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 && | |
06d53148 | 21 | git checkout main && |
32574b68 NTND |
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 | ||
38 | test_expect_success 'ref^{non-existent}' ' | |
39 | test_must_fail git rev-parse ref^{non-existent} | |
40 | ' | |
41 | ||
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 | |
48 | ' | |
49 | ||
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} | |
58 | ' | |
59 | ||
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} | |
69 | ' | |
70 | ||
75aa26d3 RH |
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 | |
76 | ' | |
77 | ||
32574b68 | 78 | test_expect_success 'ref^{/.}' ' |
06d53148 JS |
79 | git rev-parse main >expected && |
80 | git rev-parse main^{/.} >actual && | |
32574b68 NTND |
81 | test_cmp expected actual |
82 | ' | |
83 | ||
84 | test_expect_success 'ref^{/non-existent}' ' | |
06d53148 | 85 | test_must_fail git rev-parse main^{/non-existent} |
32574b68 NTND |
86 | ' |
87 | ||
88 | test_expect_success 'ref^{/Initial}' ' | |
89 | git rev-parse ref >expected && | |
06d53148 | 90 | git rev-parse main^{/Initial} >actual && |
32574b68 NTND |
91 | test_cmp expected actual |
92 | ' | |
93 | ||
06b6b68f | 94 | test_expect_success 'ref^{/!Exp}' ' |
06d53148 | 95 | test_must_fail git rev-parse main^{/!Exp} |
06b6b68f WP |
96 | ' |
97 | ||
98 | test_expect_success 'ref^{/!}' ' | |
06d53148 | 99 | test_must_fail git rev-parse main^{/!} |
06b6b68f WP |
100 | ' |
101 | ||
102 | test_expect_success 'ref^{/!!Exp}' ' | |
103 | git rev-parse expref >expected && | |
06d53148 | 104 | git rev-parse main^{/!!Exp} >actual && |
06b6b68f WP |
105 | test_cmp expected actual |
106 | ' | |
107 | ||
0769854f | 108 | test_expect_success 'ref^{/!-}' ' |
06d53148 | 109 | test_must_fail git rev-parse main^{/!-} |
0769854f WP |
110 | ' |
111 | ||
112 | test_expect_success 'ref^{/!-.}' ' | |
06d53148 | 113 | test_must_fail git rev-parse main^{/!-.} |
0769854f WP |
114 | ' |
115 | ||
116 | test_expect_success 'ref^{/!-non-existent}' ' | |
06d53148 JS |
117 | git rev-parse main >expected && |
118 | git rev-parse main^{/!-non-existent} >actual && | |
0769854f WP |
119 | test_cmp expected actual |
120 | ' | |
121 | ||
122 | test_expect_success 'ref^{/!-Changed}' ' | |
123 | git rev-parse expref >expected && | |
06d53148 | 124 | git rev-parse main^{/!-Changed} >actual && |
0769854f WP |
125 | test_cmp expected actual |
126 | ' | |
127 | ||
128 | test_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 | 134 | test_done |