path: root/date.c
diff options
authorStephen P. Smith <>2019-01-21 05:31:09 (GMT)
committerJunio C Hamano <>2019-01-22 22:16:17 (GMT)
commit2fd7c22992d37469db957e9a4d3884a6c0a4d182 (patch)
treed5ba96f68a04be1e0c62d2f24bd0e4f72288b50f /date.c
parentacdd37769de8b0fe37a74bfc0475b63bdc55e9dc (diff)
Replace the proposed 'auto' mode with 'auto:'
In addition to adding the 'human' format, the patch added the auto keyword which could be used in the config file as an alternate way to specify the human format. Removing 'auto' cleans up the 'human' format interface. Added the ability to specify mode 'foo' if the pager is being used by using auto:foo syntax. Therefore, 'auto:human' date mode defaults to human if we're using the pager. So you can do git config --add auto:human and your "git log" commands will show the human-legible format unless you're scripting things. Signed-off-by: Stephen P. Smith <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'date.c')
1 files changed, 8 insertions, 7 deletions
diff --git a/date.c b/date.c
index 4486c02..f731803 100644
--- a/date.c
+++ b/date.c
@@ -883,11 +883,6 @@ int parse_date(const char *date, struct strbuf *result)
return 0;
-static int auto_date_style(void)
- return (isatty(1) || pager_in_use()) ? DATE_HUMAN : DATE_NORMAL;
static enum date_mode_type parse_date_type(const char *format, const char **end)
if (skip_prefix(format, "relative", end))
@@ -907,8 +902,6 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
if (skip_prefix(format, "human", end))
return DATE_HUMAN;
- if (skip_prefix(format, "auto", end))
- return auto_date_style();
if (skip_prefix(format, "raw", end))
return DATE_RAW;
if (skip_prefix(format, "unix", end))
@@ -923,6 +916,14 @@ void parse_date_format(const char *format, struct date_mode *mode)
const char *p;
+ /* "auto:foo" is "if tty/pager, then foo, otherwise normal" */
+ if (skip_prefix(format, "auto:", &p)) {
+ if (isatty(1) || pager_in_use())
+ format = p;
+ else
+ format = "default";
+ }
/* historical alias */
if (!strcmp(format, "local"))
format = "default-local";