Browse Source

log --reflog: honour --relative-date

If you say "git log -g --relative-date", it is very likely that
you want to see the reflog names in terms of a relative date.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Johannes Schindelin 18 years ago committed by Junio C Hamano
parent
commit
4e244cbc5c
  1. 3
      log-tree.c
  2. 12
      reflog-walk.c
  3. 2
      reflog-walk.h

3
log-tree.c

@ -226,7 +226,8 @@ void show_log(struct rev_info *opt, const char *sep)
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n'); putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
if (opt->reflog_info) { if (opt->reflog_info) {
show_reflog_message(opt->reflog_info, show_reflog_message(opt->reflog_info,
opt->commit_format == CMIT_FMT_ONELINE);; opt->commit_format == CMIT_FMT_ONELINE,
opt->relative_date);
if (opt->commit_format == CMIT_FMT_ONELINE) { if (opt->commit_format == CMIT_FMT_ONELINE) {
printf("%s", sep); printf("%s", sep);
return; return;

12
reflog-walk.c

@ -227,7 +227,8 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
commit->object.flags &= ~(ADDED | SEEN | SHOWN); commit->object.flags &= ~(ADDED | SEEN | SHOWN);
} }


void show_reflog_message(struct reflog_walk_info* info, int oneline) void show_reflog_message(struct reflog_walk_info* info, int oneline,
int relative_date)
{ {
if (info && info->last_commit_reflog) { if (info && info->last_commit_reflog) {
struct commit_reflog *commit_reflog = info->last_commit_reflog; struct commit_reflog *commit_reflog = info->last_commit_reflog;
@ -236,7 +237,7 @@ void show_reflog_message(struct reflog_walk_info* info, int oneline)
info = &commit_reflog->reflogs->items[commit_reflog->recno+1]; info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
if (oneline) { if (oneline) {
printf("%s@{", commit_reflog->reflogs->ref); printf("%s@{", commit_reflog->reflogs->ref);
if (commit_reflog->flag) if (commit_reflog->flag || relative_date)
printf("%s", show_date(info->timestamp, 0, 1)); printf("%s", show_date(info->timestamp, 0, 1));
else else
printf("%d", commit_reflog->reflogs->nr printf("%d", commit_reflog->reflogs->nr
@ -245,9 +246,10 @@ void show_reflog_message(struct reflog_walk_info* info, int oneline)
} }
else { else {
printf("Reflog: %s@{", commit_reflog->reflogs->ref); printf("Reflog: %s@{", commit_reflog->reflogs->ref);
if (commit_reflog->flag) if (commit_reflog->flag || relative_date)
printf("%s", show_rfc2822_date(info->timestamp, printf("%s", show_date(info->timestamp,
info->tz)); info->tz,
relative_date));
else else
printf("%d", commit_reflog->reflogs->nr printf("%d", commit_reflog->reflogs->nr
- 2 - commit_reflog->recno); - 2 - commit_reflog->recno);

2
reflog-walk.h

@ -6,6 +6,6 @@ extern void add_reflog_for_walk(struct reflog_walk_info *info,
struct commit *commit, const char *name); struct commit *commit, const char *name);
extern void fake_reflog_parent(struct reflog_walk_info *info, extern void fake_reflog_parent(struct reflog_walk_info *info,
struct commit *commit); struct commit *commit);
extern void show_reflog_message(struct reflog_walk_info *info, int); extern void show_reflog_message(struct reflog_walk_info *info, int, int);


#endif #endif

Loading…
Cancel
Save