git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 14, 2019, 21:55 UTC
Message-ID
<xmqqzhlg46yg.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190712230204.16749-2-ariadne@dereferenced.org>
Ariadne Conill <ariadne@dereferenced.org> writes:
Show 9 quoted lines
> +	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.

Previous: Ariadne ConillNext: Ariadne Conill
Message 3 of 6 in “document deprecation of log.mailmap=false default”
  1. 0/3 document deprecation of log.mailmap=false defaultAriadne Conill, Jul 12, 2019
  2. 1/3 log: add warning for unspecified log.mailmap settingAriadne Conill, Jul 12, 2019
  3. Junio C HamanoJul 14, 2019
  4. 2/3 documentation: mention --no-use-mailmap and log.mailmap false settingAriadne Conill, Jul 12, 2019
  5. 3/3 tests: defang pager tests by explicitly disabling the log.mailmap warningAriadne Conill, Jul 12, 2019
  6. Junio C HamanoJul 14, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.