Skip to content

Commit dcc0a86

Browse files
avargitster
authored andcommitted
show tests: add test for "git show <tree>"
Add missing tests for showing a tree with "git show". Let's test for showing a tree, two trees, and that doing so doesn't recurse. The only tests for this code added in 5d7eeee (git-show: grok blobs, trees and tags, too, 2006-12-14) were the tests in t7701-repack-unpack-unreachable.sh added in ccc1297 (repack: modify behavior of -A option to leave unreferenced objects unpacked, 2008-05-09). Let's add this common mode of operation to the "show" tests themselves. It's more obvious, and the tests in t7701-repack-unpack-unreachable.sh happily pass if we start buggily emitting trees recursively. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent be7935e commit dcc0a86

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

t/t7007-show.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,45 @@ test_expect_success 'showing two commits' '
3838
test_cmp expect actual.filtered
3939
'
4040

41+
test_expect_success 'showing a tree' '
42+
cat >expected <<-EOF &&
43+
tree main1:
44+
45+
main1.t
46+
EOF
47+
git show main1: >actual &&
48+
test_cmp expected actual
49+
'
50+
51+
test_expect_success 'showing two trees' '
52+
cat >expected <<-EOF &&
53+
tree main1^{tree}
54+
55+
main1.t
56+
57+
tree main2^{tree}
58+
59+
main1.t
60+
main2.t
61+
EOF
62+
git show main1^{tree} main2^{tree} >actual &&
63+
test_cmp expected actual
64+
'
65+
66+
test_expect_success 'showing a trees is not recursive' '
67+
git worktree add not-recursive main1 &&
68+
mkdir not-recursive/a &&
69+
test_commit -C not-recursive a/file &&
70+
cat >expected <<-EOF &&
71+
tree HEAD^{tree}
72+
73+
a/
74+
main1.t
75+
EOF
76+
git -C not-recursive show HEAD^{tree} >actual &&
77+
test_cmp expected actual
78+
'
79+
4180
test_expect_success 'showing a range walks (linear)' '
4281
cat >expect <<-EOF &&
4382
commit $(git rev-parse main3)

0 commit comments

Comments
 (0)