@@ -241,36 +241,46 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
241
241
commit -> object .flags &= ~(ADDED | SEEN | SHOWN );
242
242
}
243
243
244
- void show_reflog_message (struct reflog_walk_info * info , int oneline ,
244
+ void get_reflog_selector (struct strbuf * sb ,
245
+ struct reflog_walk_info * reflog_info ,
246
+ enum date_mode dmode )
247
+ {
248
+ struct commit_reflog * commit_reflog = reflog_info -> last_commit_reflog ;
249
+ struct reflog_info * info ;
250
+
251
+ if (!commit_reflog )
252
+ return ;
253
+
254
+ strbuf_addf (sb , "%s@{" , commit_reflog -> reflogs -> ref );
255
+ if (commit_reflog -> flag || dmode ) {
256
+ info = & commit_reflog -> reflogs -> items [commit_reflog -> recno + 1 ];
257
+ strbuf_addstr (sb , show_date (info -> timestamp , info -> tz , dmode ));
258
+ } else {
259
+ strbuf_addf (sb , "%d" , commit_reflog -> reflogs -> nr
260
+ - 2 - commit_reflog -> recno );
261
+ }
262
+
263
+ strbuf_addch (sb , '}' );
264
+ }
265
+
266
+ void show_reflog_message (struct reflog_walk_info * reflog_info , int oneline ,
245
267
enum date_mode dmode )
246
268
{
247
- if (info && info -> last_commit_reflog ) {
248
- struct commit_reflog * commit_reflog = info -> last_commit_reflog ;
269
+ if (reflog_info && reflog_info -> last_commit_reflog ) {
270
+ struct commit_reflog * commit_reflog = reflog_info -> last_commit_reflog ;
249
271
struct reflog_info * info ;
272
+ struct strbuf selector = STRBUF_INIT ;
250
273
251
274
info = & commit_reflog -> reflogs -> items [commit_reflog -> recno + 1 ];
275
+ get_reflog_selector (& selector , reflog_info , dmode );
252
276
if (oneline ) {
253
- printf ("%s@{" , commit_reflog -> reflogs -> ref );
254
- if (commit_reflog -> flag || dmode )
255
- printf ("%s" , show_date (info -> timestamp ,
256
- info -> tz ,
257
- dmode ));
258
- else
259
- printf ("%d" , commit_reflog -> reflogs -> nr
260
- - 2 - commit_reflog -> recno );
261
- printf ("}: %s" , info -> message );
277
+ printf ("%s: %s" , selector .buf , info -> message );
262
278
}
263
279
else {
264
- printf ("Reflog: %s@{" , commit_reflog -> reflogs -> ref );
265
- if (commit_reflog -> flag || dmode )
266
- printf ("%s" , show_date (info -> timestamp ,
267
- info -> tz ,
268
- dmode ));
269
- else
270
- printf ("%d" , commit_reflog -> reflogs -> nr
271
- - 2 - commit_reflog -> recno );
272
- printf ("} (%s)\nReflog message: %s" ,
273
- info -> email , info -> message );
280
+ printf ("Reflog: %s (%s)\nReflog message: %s" ,
281
+ selector .buf , info -> email , info -> message );
274
282
}
283
+
284
+ strbuf_release (& selector );
275
285
}
276
286
}
0 commit comments