Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15
STALE3735d

[PATCH 2/2] --date=relative falls back to "short" format for commits older than a year

From: <hidden>
Date: 2016-06-15 22:46:15
Subsystem: the rest · Maintainer: Linus Torvalds

From: Eugene Letuchy <redacted>

In the context of sizing the git blame time column, it doesn't make a
lot of sense to see "12 months ago" next to an exact timestamp +
timezone for something 13 months ago. This commit makes commits older
than 12 months display the date only, not the time.

Signed-off-by: Eugene Letuchy <redacted>
---
 builtin-blame.c |    5 ++---
 date.c          |    4 +++-
 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index aa5c66c..48cedfd 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2286,9 +2286,8 @@ parse_done:
 		blame_date_width = sizeof("2006-10-19");
 		break;
 	case DATE_RELATIVE:
-		/* unfortunately "normal" is the fallback for "relative" */
-		/* blame_date_width = sizeof("14 minutes ago"); */
-		/* break; */
+		blame_date_width = sizeof("14 minutes ago");
+		break;
 	case DATE_LOCAL:
 	case DATE_NORMAL:
 		blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
diff --git a/date.c b/date.c
index 950b88f..edb2078 100644
--- a/date.c
+++ b/date.c
@@ -128,7 +128,9 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
 			snprintf(timebuf, sizeof(timebuf), "%lu months ago", (diff + 15) / 30);
 			return timebuf;
 		}
-		/* Else fall back on absolute format.. */
+
+		/* Else fall back to the short format */
+		mode = DATE_SHORT;
 	}
 
 	if (mode == DATE_LOCAL)
-- 
1.6.2.rc1.14.g07c3.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help