Merge branch 'dt/gc-ignore-old-gc-logs'
[git/gitweb.git] / t / t7007-show.sh
blob42d3db624686998f49d2fb7c80b190eee14a3e9e
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 range walks (linear)' '
42 cat >expect <<-EOF &&
43 commit $(git rev-parse main3)
44 commit $(git rev-parse main2)
45 EOF
46 git show main1..main3 >actual &&
47 grep ^commit actual >actual.filtered &&
48 test_cmp expect actual.filtered
51 test_expect_success 'showing a range walks (Y shape, ^ first)' '
52 cat >expect <<-EOF &&
53 commit $(git rev-parse main3)
54 commit $(git rev-parse main2)
55 EOF
56 git show ^side3 main3 >actual &&
57 grep ^commit actual >actual.filtered &&
58 test_cmp expect actual.filtered
61 test_expect_success 'showing a range walks (Y shape, ^ last)' '
62 cat >expect <<-EOF &&
63 commit $(git rev-parse main3)
64 commit $(git rev-parse main2)
65 EOF
66 git show main3 ^side3 >actual &&
67 grep ^commit actual >actual.filtered &&
68 test_cmp expect actual.filtered
71 test_expect_success 'showing with -N walks' '
72 cat >expect <<-EOF &&
73 commit $(git rev-parse main3)
74 commit $(git rev-parse main2)
75 EOF
76 git show -2 main3 >actual &&
77 grep ^commit actual >actual.filtered &&
78 test_cmp expect actual.filtered
81 test_expect_success 'showing annotated tag' '
82 cat >expect <<-EOF &&
83 tag annotated
84 commit $(git rev-parse annotated^{commit})
85 EOF
86 git show annotated >actual &&
87 grep -E "^(commit|tag)" actual >actual.filtered &&
88 test_cmp expect actual.filtered
91 test_expect_success 'showing annotated tag plus commit' '
92 cat >expect <<-EOF &&
93 tag annotated
94 commit $(git rev-parse annotated^{commit})
95 commit $(git rev-parse side3)
96 EOF
97 git show annotated side3 >actual &&
98 grep -E "^(commit|tag)" actual >actual.filtered &&
99 test_cmp expect actual.filtered
102 test_expect_success 'showing range' '
103 cat >expect <<-EOF &&
104 commit $(git rev-parse main3)
105 commit $(git rev-parse main2)
107 git show ^side3 annotated >actual &&
108 grep -E "^(commit|tag)" actual >actual.filtered &&
109 test_cmp expect actual.filtered
112 test_expect_success '-s suppresses diff' '
113 cat >expect <<-\EOF &&
114 merge
115 main3
117 git show -s --format=%s merge main3 >actual &&
118 test_cmp expect actual
121 test_expect_success '--quiet suppresses diff' '
122 echo main3 >expect &&
123 git show --quiet --format=%s main3 >actual &&
124 test_cmp expect actual
127 test_expect_success 'show --graph is forbidden' '
128 test_must_fail git show --graph HEAD
131 test_done