]>
Commit | Line | Data |
---|---|---|
32574b68 NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='tests for ref^{stuff}' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | echo blob >a-blob && | |
9fe281b3 | 9 | git tag -a -m blob blob-tag $(git hash-object -w a-blob) && |
32574b68 NTND |
10 | mkdir a-tree && |
11 | echo moreblobs >a-tree/another-blob && | |
12 | git add . && | |
9fe281b3 | 13 | TREE_SHA1=$(git write-tree) && |
32574b68 NTND |
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 && | |
06b6b68f WP |
21 | git commit -m Modified && |
22 | git branch modref && | |
23 | echo changed! >>a-blob && | |
24 | git add -u && | |
25 | git commit -m !Exp && | |
26 | git branch expref && | |
27 | echo changed >>a-blob && | |
28 | git add -u && | |
0769854f WP |
29 | git commit -m Changed && |
30 | echo changed-again >>a-blob && | |
31 | git add -u && | |
32 | git commit -m Changed-again | |
32574b68 NTND |
33 | ' |
34 | ||
35 | test_expect_success 'ref^{non-existent}' ' | |
36 | test_must_fail git rev-parse ref^{non-existent} | |
37 | ' | |
38 | ||
39 | test_expect_success 'ref^{}' ' | |
40 | git rev-parse ref >expected && | |
41 | git rev-parse ref^{} >actual && | |
42 | test_cmp expected actual && | |
43 | git rev-parse commit-tag^{} >actual && | |
44 | test_cmp expected actual | |
45 | ' | |
46 | ||
47 | test_expect_success 'ref^{commit}' ' | |
48 | git rev-parse ref >expected && | |
49 | git rev-parse ref^{commit} >actual && | |
50 | test_cmp expected actual && | |
51 | git rev-parse commit-tag^{commit} >actual && | |
52 | test_cmp expected actual && | |
53 | test_must_fail git rev-parse tree-tag^{commit} && | |
54 | test_must_fail git rev-parse blob-tag^{commit} | |
55 | ' | |
56 | ||
57 | test_expect_success 'ref^{tree}' ' | |
58 | echo $TREE_SHA1 >expected && | |
59 | git rev-parse ref^{tree} >actual && | |
60 | test_cmp expected actual && | |
61 | git rev-parse commit-tag^{tree} >actual && | |
62 | test_cmp expected actual && | |
63 | git rev-parse tree-tag^{tree} >actual && | |
64 | test_cmp expected actual && | |
65 | test_must_fail git rev-parse blob-tag^{tree} | |
66 | ' | |
67 | ||
75aa26d3 RH |
68 | test_expect_success 'ref^{tag}' ' |
69 | test_must_fail git rev-parse HEAD^{tag} && | |
70 | git rev-parse commit-tag >expected && | |
71 | git rev-parse commit-tag^{tag} >actual && | |
72 | test_cmp expected actual | |
73 | ' | |
74 | ||
32574b68 NTND |
75 | test_expect_success 'ref^{/.}' ' |
76 | git rev-parse master >expected && | |
77 | git rev-parse master^{/.} >actual && | |
78 | test_cmp expected actual | |
79 | ' | |
80 | ||
81 | test_expect_success 'ref^{/non-existent}' ' | |
82 | test_must_fail git rev-parse master^{/non-existent} | |
83 | ' | |
84 | ||
85 | test_expect_success 'ref^{/Initial}' ' | |
86 | git rev-parse ref >expected && | |
87 | git rev-parse master^{/Initial} >actual && | |
88 | test_cmp expected actual | |
89 | ' | |
90 | ||
06b6b68f WP |
91 | test_expect_success 'ref^{/!Exp}' ' |
92 | test_must_fail git rev-parse master^{/!Exp} | |
93 | ' | |
94 | ||
95 | test_expect_success 'ref^{/!}' ' | |
96 | test_must_fail git rev-parse master^{/!} | |
97 | ' | |
98 | ||
99 | test_expect_success 'ref^{/!!Exp}' ' | |
100 | git rev-parse expref >expected && | |
101 | git rev-parse master^{/!!Exp} >actual && | |
102 | test_cmp expected actual | |
103 | ' | |
104 | ||
0769854f WP |
105 | test_expect_success 'ref^{/!-}' ' |
106 | test_must_fail git rev-parse master^{/!-} | |
107 | ' | |
108 | ||
109 | test_expect_success 'ref^{/!-.}' ' | |
110 | test_must_fail git rev-parse master^{/!-.} | |
111 | ' | |
112 | ||
113 | test_expect_success 'ref^{/!-non-existent}' ' | |
114 | git rev-parse master >expected && | |
115 | git rev-parse master^{/!-non-existent} >actual && | |
116 | test_cmp expected actual | |
117 | ' | |
118 | ||
119 | test_expect_success 'ref^{/!-Changed}' ' | |
120 | git rev-parse expref >expected && | |
121 | git rev-parse master^{/!-Changed} >actual && | |
122 | test_cmp expected actual | |
123 | ' | |
124 | ||
125 | test_expect_success 'ref^{/!-!Exp}' ' | |
126 | git rev-parse modref >expected && | |
127 | git rev-parse expref^{/!-!Exp} >actual && | |
128 | test_cmp expected actual | |
129 | ' | |
130 | ||
32574b68 | 131 | test_done |