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 log.date auto:human and your "git log" commands will show the human-legible format unless you're scripting things. Signed-off-by: Stephen P. Smith <ischis2@cox.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen P. Smith committed Jan 20, 2019 at 22:31 UTC 2fd7c22992d37469db957e9a4d3884a6c0a4d182
1 file changed +8 -7
date.c
+8 -7
@@ -883,11 +883,6 @@ int parse_date(const char *date, struct strbuf *result)
883 return 0;
884 }
885
886 -static int auto_date_style(void)
887 -{
888 - return (isatty(1) || pager_in_use()) ? DATE_HUMAN : DATE_NORMAL;
889 -}
890 -
886 static enum date_mode_type parse_date_type(const char *format, const char **end)
887 {
888 if (skip_prefix(format, "relative", end))
@@ -907,8 +902,6 @@ static enum date_mode_type parse_date_type(const char *format, const char **end)
902 return DATE_NORMAL;
903 if (skip_prefix(format, "human", end))
904 return DATE_HUMAN;
910 - if (skip_prefix(format, "auto", end))
911 - return auto_date_style();
905 if (skip_prefix(format, "raw", end))
906 return DATE_RAW;
907 if (skip_prefix(format, "unix", end))
@@ -923,6 +916,14 @@ void parse_date_format(const char *format, struct date_mode *mode)
916 {
917 const char *p;
918
919 + /* "auto:foo" is "if tty/pager, then foo, otherwise normal" */
920 + if (skip_prefix(format, "auto:", &p)) {
921 + if (isatty(1) || pager_in_use())
922 + format = p;
923 + else
924 + format = "default";
925 + }
926 +
927 /* historical alias */
928 if (!strcmp(format, "local"))
929 format = "default-local";