3 test_description
='git show'
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' '
24 git tag -m "annotated tag" annotated &&
25 git checkout -b side HEAD^^ &&
30 test_expect_success
'showing two commits' '
32 commit $(git rev-parse main2)
33 commit $(git rev-parse main3)
35 git show main2 main3 >actual &&
36 grep ^commit actual >actual.filtered &&
37 test_cmp expect actual.filtered
40 test_expect_success
'showing a range walks (linear)' '
42 commit $(git rev-parse main3)
43 commit $(git rev-parse main2)
45 git show main1..main3 >actual &&
46 grep ^commit actual >actual.filtered &&
47 test_cmp expect actual.filtered
50 test_expect_success
'showing a range walks (Y shape, ^ first)' '
52 commit $(git rev-parse main3)
53 commit $(git rev-parse main2)
55 git show ^side3 main3 >actual &&
56 grep ^commit actual >actual.filtered &&
57 test_cmp expect actual.filtered
60 test_expect_success
'showing a range walks (Y shape, ^ last)' '
62 commit $(git rev-parse main3)
63 commit $(git rev-parse main2)
65 git show main3 ^side3 >actual &&
66 grep ^commit actual >actual.filtered &&
67 test_cmp expect actual.filtered
70 test_expect_success
'showing with -N walks' '
72 commit $(git rev-parse main3)
73 commit $(git rev-parse main2)
75 git show -2 main3 >actual &&
76 grep ^commit actual >actual.filtered &&
77 test_cmp expect actual.filtered
80 test_expect_success
'showing annotated tag' '
83 commit $(git rev-parse annotated^{commit})
85 git show annotated >actual &&
86 grep -E "^(commit|tag)" actual >actual.filtered &&
87 test_cmp expect actual.filtered
90 test_expect_success
'showing annotated tag plus commit' '
93 commit $(git rev-parse annotated^{commit})
94 commit $(git rev-parse side3)
96 git show annotated side3 >actual &&
97 grep -E "^(commit|tag)" actual >actual.filtered &&
98 test_cmp expect actual.filtered
101 test_expect_success
'showing range' '
102 cat >expect <<-EOF &&
103 commit $(git rev-parse main3)
104 commit $(git rev-parse main2)
106 git show ^side3 annotated >actual &&
107 grep -E "^(commit|tag)" actual >actual.filtered &&
108 test_cmp expect actual.filtered
111 test_expect_success
'-s suppresses diff' '
112 echo main3 >expect &&
113 git show -s --format=%s main3 >actual &&
114 test_cmp expect actual
117 test_expect_success
'--quiet suppresses diff' '
118 echo main3 >expect &&
119 git show --quiet --format=%s main3 >actual &&
120 test_cmp expect actual