]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1411-reflog-show.sh
tests: skip small-stack tests on hppa architecture
[thirdparty/git.git] / t / t1411-reflog-show.sh
CommitLineData
cd437120
JK
1#!/bin/sh
2
3test_description='Test reflog display routines'
4. ./test-lib.sh
5
6test_expect_success 'setup' '
7 echo content >file &&
8 git add file &&
9 test_tick &&
10 git commit -m one
11'
12
d3438d1a 13commit=$(git rev-parse --short HEAD)
cd437120
JK
14cat >expect <<'EOF'
15Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
16Reflog message: commit (initial): one
17EOF
18test_expect_success 'log -g shows reflog headers' '
19 git log -g -1 >tmp &&
20 grep ^Reflog <tmp >actual &&
21 test_cmp expect actual
22'
23
d3438d1a 24cat >expect <<EOF
25$commit HEAD@{0}: commit (initial): one
cd437120
JK
26EOF
27test_expect_success 'oneline reflog format' '
28 git log -g -1 --oneline >actual &&
29 test_cmp expect actual
30'
31
21d2616a
MG
32test_expect_success 'reflog default format' '
33 git reflog -1 >actual &&
34 test_cmp expect actual
35'
36
d3438d1a 37cat >expect <<EOF
38commit $commit
21d2616a
MG
39Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
40Reflog message: commit (initial): one
41Author: A U Thor <author@example.com>
42
43 one
44EOF
4b56cf58 45test_expect_success 'override reflog default format' '
21d2616a
MG
46 git reflog --format=short -1 >actual &&
47 test_cmp expect actual
48'
49
cd437120
JK
50cat >expect <<'EOF'
51Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
52Reflog message: commit (initial): one
53EOF
54test_expect_success 'using @{now} syntax shows reflog date (multiline)' '
55 git log -g -1 HEAD@{now} >tmp &&
56 grep ^Reflog <tmp >actual &&
57 test_cmp expect actual
58'
59
d3438d1a 60cat >expect <<EOF
61$commit HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
cd437120
JK
62EOF
63test_expect_success 'using @{now} syntax shows reflog date (oneline)' '
64 git log -g -1 --oneline HEAD@{now} >actual &&
65 test_cmp expect actual
66'
67
7904af1c
JK
68cat >expect <<'EOF'
69HEAD@{Thu Apr 7 15:13:13 2005 -0700}
70EOF
71test_expect_success 'using @{now} syntax shows reflog date (format=%gd)' '
72 git log -g -1 --format=%gd HEAD@{now} >actual &&
73 test_cmp expect actual
74'
75
cd437120 76cat >expect <<'EOF'
55ccf85a 77Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
cd437120
JK
78Reflog message: commit (initial): one
79EOF
80test_expect_success 'using --date= shows reflog date (multiline)' '
55ccf85a 81 git log -g -1 --date=default >tmp &&
cd437120
JK
82 grep ^Reflog <tmp >actual &&
83 test_cmp expect actual
84'
85
d3438d1a 86cat >expect <<EOF
87$commit HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
cd437120
JK
88EOF
89test_expect_success 'using --date= shows reflog date (oneline)' '
55ccf85a 90 git log -g -1 --oneline --date=default >actual &&
cd437120
JK
91 test_cmp expect actual
92'
93
7904af1c
JK
94cat >expect <<'EOF'
95HEAD@{1112911993 -0700}
96EOF
97test_expect_success 'using --date= shows reflog date (format=%gd)' '
98 git log -g -1 --format=%gd --date=raw >actual &&
99 test_cmp expect actual
100'
101
102cat >expect <<'EOF'
103Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
104Reflog message: commit (initial): one
105EOF
106test_expect_success 'log.date does not invoke "--date" magic (multiline)' '
107 test_config log.date raw &&
108 git log -g -1 >tmp &&
109 grep ^Reflog <tmp >actual &&
110 test_cmp expect actual
111'
112
d3438d1a 113cat >expect <<EOF
114$commit HEAD@{0}: commit (initial): one
7904af1c
JK
115EOF
116test_expect_success 'log.date does not invoke "--date" magic (oneline)' '
117 test_config log.date raw &&
118 git log -g -1 --oneline >actual &&
119 test_cmp expect actual
120'
121
122cat >expect <<'EOF'
123HEAD@{0}
124EOF
f026c756 125test_expect_success 'log.date does not invoke "--date" magic (format=%gd)' '
7904af1c
JK
126 test_config log.date raw &&
127 git log -g -1 --format=%gd >actual &&
128 test_cmp expect actual
129'
130
794151e9
JK
131cat >expect <<'EOF'
132HEAD@{0}
133EOF
134test_expect_success '--date magic does not override explicit @{0} syntax' '
135 git log -g -1 --format=%gd --date=raw HEAD@{0} >actual &&
136 test_cmp expect actual
137'
138
8fcaca3f
DO
139test_expect_success 'empty reflog file' '
140 git branch empty &&
d0ab0584 141 git reflog expire --expire=all refs/heads/empty &&
8fcaca3f
DO
142
143 git log -g empty >actual &&
1c5e94f4 144 test_must_be_empty actual
8fcaca3f
DO
145'
146
838f9a15
TR
147# This guards against the alternative of showing the diffs vs. the
148# reflog ancestor. The reflog used is designed to list the commits
149# more than once, so as to exercise the corresponding logic.
150test_expect_success 'git log -g -p shows diffs vs. parents' '
151 test_commit two &&
152 git branch flipflop &&
153 git update-ref refs/heads/flipflop -m flip1 HEAD^ &&
154 git update-ref refs/heads/flipflop -m flop1 HEAD &&
155 git update-ref refs/heads/flipflop -m flip2 HEAD^ &&
156 git log -g -p flipflop >reflog &&
157 grep -v ^Reflog reflog >actual &&
158 git log -1 -p HEAD^ >log.one &&
159 git log -1 -p HEAD >log.two &&
160 (
f2deabfc
ES
161 cat log.one && echo &&
162 cat log.two && echo &&
163 cat log.one && echo &&
838f9a15
TR
164 cat log.two
165 ) >expect &&
166 test_cmp expect actual
167'
168
afcb2e7a
DT
169test_expect_success 'reflog exists works' '
170 git reflog exists refs/heads/master &&
171 ! git reflog exists refs/heads/nonexistent
172'
173
cd437120 174test_done