1#!/bin/sh
2#
3# Copyright (c) 2005 Johannes Schindelin
4#
56
test_description='Test git rev-parse with different parent options'
78
. ./test-lib.sh
910
test_cmp_rev_output () {
11git rev-parse --verify "$1" >expect &&
12eval "$2" >actual &&
13test_cmp expect actual
14}
1516
test_expect_success 'setup' '
17test_commit start &&
18test_commit second &&
19git checkout --orphan tmp &&
20test_commit start2 &&
21git checkout master &&
22git merge -m next start2 &&
23test_commit final
24'
2526
test_expect_success 'start is valid' '
27git rev-parse start | grep "^[0-9a-f]\{40\}$"
28'
2930
test_expect_success 'start^0' '
31test_cmp_rev_output tags/start "git rev-parse start^0"
32'
3334
test_expect_success 'start^1 not valid' '
35test_must_fail git rev-parse --verify start^1
36'
3738
test_expect_success 'second^1 = second^' '
39test_cmp_rev_output second^ "git rev-parse second^1"
40'
4142
test_expect_success 'final^1^1^1' '
43test_cmp_rev_output start "git rev-parse final^1^1^1"
44'
4546
test_expect_success 'final^1^1^1 = final^^^' '
47test_cmp_rev_output final^^^ "git rev-parse final^1^1^1"
48'
4950
test_expect_success 'final^1^2' '
51test_cmp_rev_output start2 "git rev-parse final^1^2"
52'
5354
test_expect_success 'final^1^2 != final^1^1' '
55test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)
56'
5758
test_expect_success 'final^1^3 not valid' '
59test_must_fail git rev-parse --verify final^1^3
60'
6162
test_expect_success '--verify start2^1' '
63test_must_fail git rev-parse --verify start2^1
64'
6566
test_expect_success '--verify start2^0' '
67git rev-parse --verify start2^0
68'
6970
test_expect_success 'final^1^@ = final^1^1 final^1^2' '
71git rev-parse final^1^1 final^1^2 >expect &&
72git rev-parse final^1^@ >actual &&
73test_cmp expect actual
74'
7576
test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' '
77git rev-parse final^1 ^final^1^1 ^final^1^2 >expect &&
78git rev-parse final^1^! >actual &&
79test_cmp expect actual
80'
8182
test_expect_success 'repack for next test' '
83git repack -a -d
84'
8586
test_expect_success 'short SHA-1 works' '
87start=$(git rev-parse --verify start) &&
88test_cmp_rev_output start "git rev-parse ${start%?}"
89'
9091
test_done