Skip to content

Commit 55ccf85

Browse files
committed
reflog-walk: tell explicit --date=default from not having --date at all
Introduction of opt->date_mode_explicit was a step in the right direction, but lost that crucial bit at the very end of the callchain, and the callee could not tell an explicitly specified "I want *date* but in default format" from the built-in default value passed when there was no --date specified. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 794151e commit 55ccf85

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

log-tree.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,9 @@ void show_log(struct rev_info *opt)
493493
* graph info here.
494494
*/
495495
show_reflog_message(opt->reflog_info,
496-
opt->commit_format == CMIT_FMT_ONELINE,
497-
opt->date_mode_explicit ?
498-
opt->date_mode :
499-
DATE_NORMAL);
496+
opt->commit_format == CMIT_FMT_ONELINE,
497+
opt->date_mode,
498+
opt->date_mode_explicit);
500499
if (opt->commit_format == CMIT_FMT_ONELINE)
501500
return;
502501
}

pretty.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
956956
if (c->pretty_ctx->reflog_info)
957957
get_reflog_selector(sb,
958958
c->pretty_ctx->reflog_info,
959-
c->pretty_ctx->date_mode_explicit ?
960-
c->pretty_ctx->date_mode :
961-
DATE_NORMAL,
959+
c->pretty_ctx->date_mode,
960+
c->pretty_ctx->date_mode_explicit,
962961
(placeholder[1] == 'd'));
963962
return 2;
964963
case 's': /* reflog message */

reflog-walk.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
252252

253253
void get_reflog_selector(struct strbuf *sb,
254254
struct reflog_walk_info *reflog_info,
255-
enum date_mode dmode,
255+
enum date_mode dmode, int force_date,
256256
int shorten)
257257
{
258258
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
@@ -273,7 +273,7 @@ void get_reflog_selector(struct strbuf *sb,
273273

274274
strbuf_addf(sb, "%s@{", printed_ref);
275275
if (commit_reflog->selector == SELECTOR_DATE ||
276-
(commit_reflog->selector == SELECTOR_NONE && dmode)) {
276+
(commit_reflog->selector == SELECTOR_NONE && force_date)) {
277277
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
278278
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
279279
} else {
@@ -302,15 +302,15 @@ void get_reflog_message(struct strbuf *sb,
302302
}
303303

304304
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
305-
enum date_mode dmode)
305+
enum date_mode dmode, int force_date)
306306
{
307307
if (reflog_info && reflog_info->last_commit_reflog) {
308308
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
309309
struct reflog_info *info;
310310
struct strbuf selector = STRBUF_INIT;
311311

312312
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
313-
get_reflog_selector(&selector, reflog_info, dmode, 0);
313+
get_reflog_selector(&selector, reflog_info, dmode, force_date, 0);
314314
if (oneline) {
315315
printf("%s: %s", selector.buf, info->message);
316316
}

reflog-walk.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ extern int add_reflog_for_walk(struct reflog_walk_info *info,
1111
extern void fake_reflog_parent(struct reflog_walk_info *info,
1212
struct commit *commit);
1313
extern void show_reflog_message(struct reflog_walk_info *info, int,
14-
enum date_mode);
14+
enum date_mode, int force_date);
1515
extern void get_reflog_message(struct strbuf *sb,
1616
struct reflog_walk_info *reflog_info);
1717
extern void get_reflog_selector(struct strbuf *sb,
1818
struct reflog_walk_info *reflog_info,
19-
enum date_mode dmode,
19+
enum date_mode dmode, int force_date,
2020
int shorten);
2121

2222
#endif

t/t1411-reflog-show.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ test_expect_success 'using @{now} syntax shows reflog date (format=%gd)' '
7373
'
7474

7575
cat >expect <<'EOF'
76-
Reflog: HEAD@{1112911993 -0700} (C O Mitter <[email protected]>)
76+
Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <[email protected]>)
7777
Reflog message: commit (initial): one
7878
EOF
7979
test_expect_success 'using --date= shows reflog date (multiline)' '
80-
git log -g -1 --date=raw >tmp &&
80+
git log -g -1 --date=default >tmp &&
8181
grep ^Reflog <tmp >actual &&
8282
test_cmp expect actual
8383
'
8484

8585
cat >expect <<'EOF'
86-
e46513e HEAD@{1112911993 -0700}: commit (initial): one
86+
e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
8787
EOF
8888
test_expect_success 'using --date= shows reflog date (oneline)' '
89-
git log -g -1 --oneline --date=raw >actual &&
89+
git log -g -1 --oneline --date=default >actual &&
9090
test_cmp expect actual
9191
'
9292

0 commit comments

Comments
 (0)