3 test_description
='Test reflog display routines'
6 test_expect_success
'setup' '
14 Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
15 Reflog message: commit (initial): one
17 test_expect_success
'log -g shows reflog headers' '
19 grep ^Reflog <tmp >actual &&
20 test_cmp expect actual
24 e46513e HEAD@{0}: commit (initial): one
26 test_expect_success
'oneline reflog format' '
27 git log -g -1 --oneline >actual &&
28 test_cmp expect actual
31 test_expect_success
'reflog default format' '
32 git reflog -1 >actual &&
33 test_cmp expect actual
38 Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
39 Reflog message: commit (initial): one
40 Author: A U Thor <author@example.com>
44 test_expect_success
'override reflog default format' '
45 git reflog --format=short -1 >actual &&
46 test_cmp expect actual
50 Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
51 Reflog message: commit (initial): one
53 test_expect_success
'using @{now} syntax shows reflog date (multiline)' '
54 git log -g -1 HEAD@{now} >tmp &&
55 grep ^Reflog <tmp >actual &&
56 test_cmp expect actual
60 e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
62 test_expect_success
'using @{now} syntax shows reflog date (oneline)' '
63 git log -g -1 --oneline HEAD@{now} >actual &&
64 test_cmp expect actual
68 HEAD@{Thu Apr 7 15:13:13 2005 -0700}
70 test_expect_success
'using @{now} syntax shows reflog date (format=%gd)' '
71 git log -g -1 --format=%gd HEAD@{now} >actual &&
72 test_cmp expect actual
76 Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
77 Reflog message: commit (initial): one
79 test_expect_success
'using --date= shows reflog date (multiline)' '
80 git log -g -1 --date=default >tmp &&
81 grep ^Reflog <tmp >actual &&
82 test_cmp expect actual
86 e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
88 test_expect_success
'using --date= shows reflog date (oneline)' '
89 git log -g -1 --oneline --date=default >actual &&
90 test_cmp expect actual
94 HEAD@{1112911993 -0700}
96 test_expect_success
'using --date= shows reflog date (format=%gd)' '
97 git log -g -1 --format=%gd --date=raw >actual &&
98 test_cmp expect actual
102 Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
103 Reflog message: commit (initial): one
105 test_expect_success
'log.date does not invoke "--date" magic (multiline)' '
106 test_config log.date raw &&
107 git log -g -1 >tmp &&
108 grep ^Reflog <tmp >actual &&
109 test_cmp expect actual
113 e46513e HEAD@{0}: commit (initial): one
115 test_expect_success
'log.date does not invoke "--date" magic (oneline)' '
116 test_config log.date raw &&
117 git log -g -1 --oneline >actual &&
118 test_cmp expect actual
124 test_expect_success
'log.date does not invoke "--date" magic (format=%gd)' '
125 test_config log.date raw &&
126 git log -g -1 --format=%gd >actual &&
127 test_cmp expect actual
133 test_expect_success
'--date magic does not override explicit @{0} syntax' '
134 git log -g -1 --format=%gd --date=raw HEAD@{0} >actual &&
135 test_cmp expect actual
139 test_expect_success
'empty reflog file' '
141 git reflog expire --expire=all refs/heads/empty &&
143 git log -g empty >actual &&
144 test_cmp expect actual
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.
150 test_expect_success
'git log -g -p shows diffs vs. parents' '
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 &&
166 test_cmp expect actual
169 test_expect_success
'reflog exists works' '
170 git reflog exists refs/heads/master &&
171 ! git reflog exists refs/heads/nonexistent