@matheusbsbs / matheus-bagliano / commits / f4ea32f0b4
Fork 0

improve reflog date/number heuristic

When we show a reflog, we have two ways of naming the entry: by sequence number (e.g., HEAD@{0}) or by date (e.g., HEAD@{10 minutes ago}). There is no explicit option to set one or the other, but we guess based on whether or not the user has provided us with a date format, showing them the date version if they have done so, and the sequence number otherwise. This usually made sense if the use did something like "git log -g --date=relative". However, it didn't make much sense if the user set the date format using the log.date config variable; in that case, all of their reflogs would end up as dates. This patch records the source of the date format and only triggers the date-based view if --date= was given on the command line. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Jeff King committed Sep 24, 2009 at 04:28 UTC f4ea32f0b48bc300afcb7c980c5a294deba31daa
3 files changed +7 -2
log-tree.c
+3 -1
@@ -390,7 +390,9 @@ void show_log(struct rev_info *opt)
390 */
391 show_reflog_message(opt->reflog_info,
392 opt->commit_format == CMIT_FMT_ONELINE,
393 - opt->date_mode);
393 + opt->date_mode_explicit ?
394 + opt->date_mode :
395 + DATE_NORMAL);
396 if (opt->commit_format == CMIT_FMT_ONELINE)
397 return;
398 }
revision.c
+2
@@ -1159,8 +1159,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1159 revs->simplify_history = 0;
1160 } else if (!strcmp(arg, "--relative-date")) {
1161 revs->date_mode = DATE_RELATIVE;
1162 + revs->date_mode_explicit = 1;
1163 } else if (!strncmp(arg, "--date=", 7)) {
1164 revs->date_mode = parse_date_format(arg + 7);
1165 + revs->date_mode_explicit = 1;
1166 } else if (!strcmp(arg, "--log-size")) {
1167 revs->show_log_size = 1;
1168 }
revision.h
+2 -1
@@ -81,7 +81,8 @@ struct rev_info {
81 show_merge:1,
82 abbrev_commit:1,
83 use_terminator:1,
84 - missing_newline:1;
84 + missing_newline:1,
85 + date_mode_explicit:1;
86 enum date_mode date_mode;
87
88 unsigned int abbrev;