diff --git a/reflog-walk.c b/reflog-walk.c index 80bffb0a00..b84e80f2ca 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -272,7 +272,8 @@ void get_reflog_selector(struct strbuf *sb, } strbuf_addf(sb, "%s@{", printed_ref); - if (commit_reflog->selector == SELECTOR_DATE || dmode) { + if (commit_reflog->selector == SELECTOR_DATE || + (commit_reflog->selector == SELECTOR_NONE && dmode)) { info = &commit_reflog->reflogs->items[commit_reflog->recno+1]; strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode)); } else { diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh index 88247f874e..7d9b5e33df 100755 --- a/t/t1411-reflog-show.sh +++ b/t/t1411-reflog-show.sh @@ -127,6 +127,14 @@ test_expect_success 'log.date does not invoke "--date" magic (format=%gd)' ' test_cmp expect actual ' +cat >expect <<'EOF' +HEAD@{0} +EOF +test_expect_success '--date magic does not override explicit @{0} syntax' ' + git log -g -1 --format=%gd --date=raw HEAD@{0} >actual && + test_cmp expect actual +' + : >expect test_expect_success 'empty reflog file' ' git branch empty &&