3 test_description
='Tests for rev-parse --prefix'
7 test_expect_success
'setup' '
10 echo file1 >sub1/file1 &&
11 echo file2 >sub1/sub2/file2 &&
12 git add top sub1/file1 sub1/sub2/file2 &&
16 test_expect_success
'empty prefix -- file' '
17 git rev-parse --prefix "" -- top sub1/file1 >actual &&
18 cat <<-\EOF >expected &&
23 test_cmp expected actual
26 test_expect_success
'valid prefix -- file' '
27 git rev-parse --prefix sub1/ -- file1 sub2/file2 >actual &&
28 cat <<-\EOF >expected &&
33 test_cmp expected actual
36 test_expect_success
'valid prefix -- ../file' '
37 git rev-parse --prefix sub1/ -- ../top sub2/file2 >actual &&
38 cat <<-\EOF >expected &&
43 test_cmp expected actual
46 test_expect_success
'empty prefix HEAD:./path' '
47 git rev-parse --prefix "" HEAD:./top >actual &&
48 git rev-parse HEAD:top >expected &&
49 test_cmp expected actual
52 test_expect_success
'valid prefix HEAD:./path' '
53 git rev-parse --prefix sub1/ HEAD:./file1 >actual &&
54 git rev-parse HEAD:sub1/file1 >expected &&
55 test_cmp expected actual
58 test_expect_success
'valid prefix HEAD:../path' '
59 git rev-parse --prefix sub1/ HEAD:../top >actual &&
60 git rev-parse HEAD:top >expected &&
61 test_cmp expected actual
64 test_expect_success
'prefix ignored with HEAD:top' '
65 git rev-parse --prefix sub1/ HEAD:top >actual &&
66 git rev-parse HEAD:top >expected &&
67 test_cmp expected actual
70 test_expect_success
'disambiguate path with valid prefix' '
71 git rev-parse --prefix sub1/ file1 >actual &&
72 cat <<-\EOF >expected &&
75 test_cmp expected actual
78 test_expect_success
'file and refs with prefix' '
79 git rev-parse --prefix sub1/ master file1 >actual &&
80 cat <<-EOF >expected &&
81 $(git rev-parse master)
84 test_cmp expected actual
87 test_expect_success
'two-levels deep' '
88 git rev-parse --prefix sub1/sub2/ -- file2 >actual &&
89 cat <<-\EOF >expected &&
93 test_cmp expected actual