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 <gitster@pobox.com>
Junio C Hamano committed
May 7, 2012 at 14:11 UTC
55ccf85a524f6a2d8cb5582d80a2927ff11dfb64
5 files changed
+15
-17
log-tree.c
+3
-4
@@ -493,10 +493,9 @@ void show_log(struct rev_info *opt)
493
* graph info here.
494
*/
495
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);
499
if (opt->commit_format == CMIT_FMT_ONELINE)
500
return;
501
}
pretty.c
+2
-3
@@ -956,9 +956,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
956
if (c->pretty_ctx->reflog_info)
957
get_reflog_selector(sb,
958
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,
961
(placeholder[1] == 'd'));
962
return 2;
963
case 's': /* reflog message */
reflog-walk.c
+4
-4
@@ -252,7 +252,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
252
253
void get_reflog_selector(struct strbuf *sb,
254
struct reflog_walk_info *reflog_info,
255
- enum date_mode dmode,
255
+ enum date_mode dmode, int force_date,
256
int shorten)
257
{
258
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
@@ -273,7 +273,7 @@ void get_reflog_selector(struct strbuf *sb,
273
274
strbuf_addf(sb, "%s@{", printed_ref);
275
if (commit_reflog->selector == SELECTOR_DATE ||
276
- (commit_reflog->selector == SELECTOR_NONE && dmode)) {
276
+ (commit_reflog->selector == SELECTOR_NONE && force_date)) {
277
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
278
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
279
} else {
@@ -302,7 +302,7 @@ void get_reflog_message(struct strbuf *sb,
302
}
303
304
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)
306
{
307
if (reflog_info && reflog_info->last_commit_reflog) {
308
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
@@ -310,7 +310,7 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
310
struct strbuf selector = STRBUF_INIT;
311
312
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);
314
if (oneline) {
315
printf("%s: %s", selector.buf, info->message);
316
}
reflog-walk.h
+2
-2
@@ -11,12 +11,12 @@ extern int add_reflog_for_walk(struct reflog_walk_info *info,
11
extern void fake_reflog_parent(struct reflog_walk_info *info,
12
struct commit *commit);
13
extern void show_reflog_message(struct reflog_walk_info *info, int,
14
- enum date_mode);
14
+ enum date_mode, int force_date);
15
extern void get_reflog_message(struct strbuf *sb,
16
struct reflog_walk_info *reflog_info);
17
extern void get_reflog_selector(struct strbuf *sb,
18
struct reflog_walk_info *reflog_info,
19
- enum date_mode dmode,
19
+ enum date_mode dmode, int force_date,
20
int shorten);
21
22
#endif
t/t1411-reflog-show.sh
+4
-4
@@ -73,20 +73,20 @@ test_expect_success 'using @{now} syntax shows reflog date (format=%gd)' '
73
'
74
75
cat >expect <<'EOF'
76
-Reflog: HEAD@{1112911993 -0700} (C O Mitter <committer@example.com>)
76
+Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
77
Reflog message: commit (initial): one
78
EOF
79
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 &&
81
grep ^Reflog <tmp >actual &&
82
test_cmp expect actual
83
'
84
85
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
87
EOF
88
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 &&
90
test_cmp expect actual
91
'
92