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>
This commit is contained in:
parent
794151e9b5
commit
55ccf85a52
@ -494,9 +494,8 @@ void show_log(struct rev_info *opt)
|
|||||||
*/
|
*/
|
||||||
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->date_mode_explicit ?
|
opt->date_mode,
|
||||||
opt->date_mode :
|
opt->date_mode_explicit);
|
||||||
DATE_NORMAL);
|
|
||||||
if (opt->commit_format == CMIT_FMT_ONELINE)
|
if (opt->commit_format == CMIT_FMT_ONELINE)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
5
pretty.c
5
pretty.c
@ -956,9 +956,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
|
|||||||
if (c->pretty_ctx->reflog_info)
|
if (c->pretty_ctx->reflog_info)
|
||||||
get_reflog_selector(sb,
|
get_reflog_selector(sb,
|
||||||
c->pretty_ctx->reflog_info,
|
c->pretty_ctx->reflog_info,
|
||||||
c->pretty_ctx->date_mode_explicit ?
|
c->pretty_ctx->date_mode,
|
||||||
c->pretty_ctx->date_mode :
|
c->pretty_ctx->date_mode_explicit,
|
||||||
DATE_NORMAL,
|
|
||||||
(placeholder[1] == 'd'));
|
(placeholder[1] == 'd'));
|
||||||
return 2;
|
return 2;
|
||||||
case 's': /* reflog message */
|
case 's': /* reflog message */
|
||||||
|
@ -252,7 +252,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
|
|||||||
|
|
||||||
void get_reflog_selector(struct strbuf *sb,
|
void get_reflog_selector(struct strbuf *sb,
|
||||||
struct reflog_walk_info *reflog_info,
|
struct reflog_walk_info *reflog_info,
|
||||||
enum date_mode dmode,
|
enum date_mode dmode, int force_date,
|
||||||
int shorten)
|
int shorten)
|
||||||
{
|
{
|
||||||
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
|
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
|
||||||
@ -273,7 +273,7 @@ void get_reflog_selector(struct strbuf *sb,
|
|||||||
|
|
||||||
strbuf_addf(sb, "%s@{", printed_ref);
|
strbuf_addf(sb, "%s@{", printed_ref);
|
||||||
if (commit_reflog->selector == SELECTOR_DATE ||
|
if (commit_reflog->selector == SELECTOR_DATE ||
|
||||||
(commit_reflog->selector == SELECTOR_NONE && dmode)) {
|
(commit_reflog->selector == SELECTOR_NONE && force_date)) {
|
||||||
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
||||||
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
|
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
|
||||||
} else {
|
} else {
|
||||||
@ -302,7 +302,7 @@ void get_reflog_message(struct strbuf *sb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
|
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
|
||||||
enum date_mode dmode)
|
enum date_mode dmode, int force_date)
|
||||||
{
|
{
|
||||||
if (reflog_info && reflog_info->last_commit_reflog) {
|
if (reflog_info && reflog_info->last_commit_reflog) {
|
||||||
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
|
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,
|
|||||||
struct strbuf selector = STRBUF_INIT;
|
struct strbuf selector = STRBUF_INIT;
|
||||||
|
|
||||||
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
|
||||||
get_reflog_selector(&selector, reflog_info, dmode, 0);
|
get_reflog_selector(&selector, reflog_info, dmode, force_date, 0);
|
||||||
if (oneline) {
|
if (oneline) {
|
||||||
printf("%s: %s", selector.buf, info->message);
|
printf("%s: %s", selector.buf, info->message);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ extern int add_reflog_for_walk(struct reflog_walk_info *info,
|
|||||||
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,
|
||||||
enum date_mode);
|
enum date_mode, int force_date);
|
||||||
extern void get_reflog_message(struct strbuf *sb,
|
extern void get_reflog_message(struct strbuf *sb,
|
||||||
struct reflog_walk_info *reflog_info);
|
struct reflog_walk_info *reflog_info);
|
||||||
extern void get_reflog_selector(struct strbuf *sb,
|
extern void get_reflog_selector(struct strbuf *sb,
|
||||||
struct reflog_walk_info *reflog_info,
|
struct reflog_walk_info *reflog_info,
|
||||||
enum date_mode dmode,
|
enum date_mode dmode, int force_date,
|
||||||
int shorten);
|
int shorten);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,20 +73,20 @@ test_expect_success 'using @{now} syntax shows reflog date (format=%gd)' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
cat >expect <<'EOF'
|
cat >expect <<'EOF'
|
||||||
Reflog: HEAD@{1112911993 -0700} (C O Mitter <committer@example.com>)
|
Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
|
||||||
Reflog message: commit (initial): one
|
Reflog message: commit (initial): one
|
||||||
EOF
|
EOF
|
||||||
test_expect_success 'using --date= shows reflog date (multiline)' '
|
test_expect_success 'using --date= shows reflog date (multiline)' '
|
||||||
git log -g -1 --date=raw >tmp &&
|
git log -g -1 --date=default >tmp &&
|
||||||
grep ^Reflog <tmp >actual &&
|
grep ^Reflog <tmp >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
cat >expect <<'EOF'
|
cat >expect <<'EOF'
|
||||||
e46513e HEAD@{1112911993 -0700}: commit (initial): one
|
e46513e HEAD@{Thu Apr 7 15:13:13 2005 -0700}: commit (initial): one
|
||||||
EOF
|
EOF
|
||||||
test_expect_success 'using --date= shows reflog date (oneline)' '
|
test_expect_success 'using --date= shows reflog date (oneline)' '
|
||||||
git log -g -1 --oneline --date=raw >actual &&
|
git log -g -1 --oneline --date=default >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user