Re: [PATCH v2 2/5] Remove the proposed use of auto as secondary way to specify human

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Stephen P. Smith" <ischis2@xxxxxxx> writes:

> 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.
>
> Instead add 'auto:human' date mode which 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.

I think doing two things in this step (i.e. reverting Linus's "auto"
support from 1/5, and adding "auto" that is similar to color's auto)
is OK, but then the title should list both.  It sounded like it was
this step is doing only the former.

>
> Signed-off-by: Stephen P. Smith <ischis2@xxxxxxx>
> ---
>  date.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/date.c b/date.c
> index a8d50eb206..43c3a84e25 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)
>  		return DATE_NORMAL;
>  	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";



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux