Re: [PATCH v2 1/3] log: add warning for unspecified log.mailmap setting

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

 



Ariadne Conill <ariadne@xxxxxxxxxxxxxxxx> writes:

> +	if (mailmap < 0) {
> +		/*
> +		 * Only display the warning if the session is interactive
> +		 * and pretty_given is false. We determine that the session
> +		 * is interactive by checking if auto_decoration_style()
> +		 * returns non-zero.
> +		 */
> +		if (auto_decoration_style() && !rev->pretty_given)
> +			warning("%s\n", _(warn_unspecified_mailmap_msg));

The huge comment can go if you refactored the helper function a
little bit and will give us a much better better organization.

static int auto_decoration_style(void)
{
	return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0;
}

The existing helper is meant to help those who are interested in the
decoration feature, and the fact that it kicks in by default when
the condition (isatty(1) || pager_in_use()) is true is a mere
"decoration feature happens to be designed that way right now".
There is no logical reason to expect that the decoration feature and
mailmap feature's advicse messages will be triggered by the same
condition forever.

Think a bit and what the condition "means".  You wrote a good one
yourself above: "the session is interactive".  Introduce a helper
that checks exatly that, by reusing what auto_decoration_style()
already uses. i.e.

	static int session_is_interactive(void)
	{
		return isatty(1) || pager_in_use();
	}

	static int auto_decoration_style(void)
	{
		return session_is_interactive() ? DECORATE_SHORT_REFS : 0;
	}

and then the above hunk becomes

	if (session_is_interactive() && !rev->pretty_given)
		warning(...);

It is clear enough and there is no need for your 2 sentence comment,
as (1) the first sentence is exactly what the implementation is, and
(2) we no longer abuse auto_decoration_style() outside its intended
purpose.







[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