Skip to content

Commit

Permalink
show tests: add test for "git show <tree>"
Browse files Browse the repository at this point in the history
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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
avar authored and gitster committed Mar 20, 2021
1 parent be7935e commit dcc0a86
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions t/t7007-show.sh
Expand Up @@ -38,6 +38,45 @@ test_expect_success 'showing two commits' '
test_cmp expect actual.filtered
'

test_expect_success 'showing a tree' '
cat >expected <<-EOF &&
tree main1:
main1.t
EOF
git show main1: >actual &&
test_cmp expected actual
'

test_expect_success 'showing two trees' '
cat >expected <<-EOF &&
tree main1^{tree}
main1.t
tree main2^{tree}
main1.t
main2.t
EOF
git show main1^{tree} main2^{tree} >actual &&
test_cmp expected actual
'

test_expect_success 'showing a trees is not recursive' '
git worktree add not-recursive main1 &&
mkdir not-recursive/a &&
test_commit -C not-recursive a/file &&
cat >expected <<-EOF &&
tree HEAD^{tree}
a/
main1.t
EOF
git -C not-recursive show HEAD^{tree} >actual &&
test_cmp expected actual
'

test_expect_success 'showing a range walks (linear)' '
cat >expect <<-EOF &&
commit $(git rev-parse main3)
Expand Down

0 comments on commit dcc0a86

Please sign in to comment.