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 5d7eeee2ac6 (git-show: grok blobs, trees and tags, too, 2006-12-14) were the tests in t7701-repack-unpack-unreachable.sh added in ccc1297226b (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>
Ævar Arnfjörð Bjarmason committed
Mar 20, 2021 at 23:37 UTC
dcc0a86f2f2f036b3a379f41a4b754f8bb73ed6b
1 file changed
+39
t/t7007-show.sh
+39
@@ -38,6 +38,45 @@ test_expect_success 'showing two commits' '
38
test_cmp expect actual.filtered
39
'
40
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
+
80
test_expect_success 'showing a range walks (linear)' '
81
cat >expect <<-EOF &&
82
commit $(git rev-parse main3)