]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1511-rev-parse-caret.sh
Merge branch 'jc/check-attr-honor-working-tree' into maint
[thirdparty/git.git] / t / t1511-rev-parse-caret.sh
CommitLineData
32574b68
NTND
1#!/bin/sh
2
3test_description='tests for ref^{stuff}'
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 echo blob >a-blob &&
02380389 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 . &&
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
22'
23
24test_expect_success 'ref^{non-existent}' '
25 test_must_fail git rev-parse ref^{non-existent}
26'
27
28test_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
34'
35
36test_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}
44'
45
46test_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}
55'
56
75aa26d3
RH
57test_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
62'
63
32574b68
NTND
64test_expect_success 'ref^{/.}' '
65 git rev-parse master >expected &&
66 git rev-parse master^{/.} >actual &&
67 test_cmp expected actual
68'
69
70test_expect_success 'ref^{/non-existent}' '
71 test_must_fail git rev-parse master^{/non-existent}
72'
73
74test_expect_success 'ref^{/Initial}' '
75 git rev-parse ref >expected &&
76 git rev-parse master^{/Initial} >actual &&
77 test_cmp expected actual
78'
79
80test_done