Makefile: FreeBSD cannot do C99-or-below build
[git/debian.git] / t / t7007-show.sh
blobd6cc69e0f2cbd576ff6ff81720de63f1e9cf86bf
1 #!/bin/sh
3 test_description='git show'
5 . ./test-lib.sh
7 test_expect_success setup '
8 echo hello world >foo &&
9 H=$(git hash-object -w foo) &&
10 git tag -a foo-tag -m "Tags $H" $H &&
11 HH=$(expr "$H" : "\(..\)") &&
12 H38=$(expr "$H" : "..\(.*\)") &&
13 rm -f .git/objects/$HH/$H38
16 test_expect_success 'showing a tag that point at a missing object' '
17 test_must_fail git --no-pager show foo-tag
20 test_expect_success 'set up a bit of history' '
21 test_commit main1 &&
22 test_commit main2 &&
23 test_commit main3 &&
24 git tag -m "annotated tag" annotated &&
25 git checkout -b side HEAD^^ &&
26 test_commit side2 &&
27 test_commit side3 &&
28 test_merge merge main3
31 test_expect_success 'showing two commits' '
32 cat >expect <<-EOF &&
33 commit $(git rev-parse main2)
34 commit $(git rev-parse main3)
35 EOF
36 git show main2 main3 >actual &&
37 grep ^commit actual >actual.filtered &&
38 test_cmp expect actual.filtered
41 test_expect_success 'showing a tree' '
42 cat >expected <<-EOF &&
43 tree main1:
45 main1.t
46 EOF
47 git show main1: >actual &&
48 test_cmp expected actual
51 test_expect_success 'showing two trees' '
52 cat >expected <<-EOF &&
53 tree main1^{tree}
55 main1.t
57 tree main2^{tree}
59 main1.t
60 main2.t
61 EOF
62 git show main1^{tree} main2^{tree} >actual &&
63 test_cmp expected actual
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}
74 main1.t
75 EOF
76 git -C not-recursive show HEAD^{tree} >actual &&
77 test_cmp expected actual
80 test_expect_success 'showing a range walks (linear)' '
81 cat >expect <<-EOF &&
82 commit $(git rev-parse main3)
83 commit $(git rev-parse main2)
84 EOF
85 git show main1..main3 >actual &&
86 grep ^commit actual >actual.filtered &&
87 test_cmp expect actual.filtered
90 test_expect_success 'showing a range walks (Y shape, ^ first)' '
91 cat >expect <<-EOF &&
92 commit $(git rev-parse main3)
93 commit $(git rev-parse main2)
94 EOF
95 git show ^side3 main3 >actual &&
96 grep ^commit actual >actual.filtered &&
97 test_cmp expect actual.filtered
100 test_expect_success 'showing a range walks (Y shape, ^ last)' '
101 cat >expect <<-EOF &&
102 commit $(git rev-parse main3)
103 commit $(git rev-parse main2)
105 git show main3 ^side3 >actual &&
106 grep ^commit actual >actual.filtered &&
107 test_cmp expect actual.filtered
110 test_expect_success 'showing with -N walks' '
111 cat >expect <<-EOF &&
112 commit $(git rev-parse main3)
113 commit $(git rev-parse main2)
115 git show -2 main3 >actual &&
116 grep ^commit actual >actual.filtered &&
117 test_cmp expect actual.filtered
120 test_expect_success 'showing annotated tag' '
121 cat >expect <<-EOF &&
122 tag annotated
123 commit $(git rev-parse annotated^{commit})
125 git show annotated >actual &&
126 grep -E "^(commit|tag)" actual >actual.filtered &&
127 test_cmp expect actual.filtered
130 test_expect_success 'showing annotated tag plus commit' '
131 cat >expect <<-EOF &&
132 tag annotated
133 commit $(git rev-parse annotated^{commit})
134 commit $(git rev-parse side3)
136 git show annotated side3 >actual &&
137 grep -E "^(commit|tag)" actual >actual.filtered &&
138 test_cmp expect actual.filtered
141 test_expect_success 'showing range' '
142 cat >expect <<-EOF &&
143 commit $(git rev-parse main3)
144 commit $(git rev-parse main2)
146 git show ^side3 annotated >actual &&
147 grep -E "^(commit|tag)" actual >actual.filtered &&
148 test_cmp expect actual.filtered
151 test_expect_success '-s suppresses diff' '
152 cat >expect <<-\EOF &&
153 merge
154 main3
156 git show -s --format=%s merge main3 >actual &&
157 test_cmp expect actual
160 test_expect_success '--quiet suppresses diff' '
161 echo main3 >expect &&
162 git show --quiet --format=%s main3 >actual &&
163 test_cmp expect actual
166 test_expect_success 'show --graph is forbidden' '
167 test_must_fail git show --graph HEAD
170 test_done