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

Re: [PATCH v6 2/2] config: allow giving separate author and committer idents

From
Derrick Stolee <stolee@gmail.com>
Date
Apr 15, 2019, 14:24 UTC
Message-ID
<15f17152-fcec-ee9a-acd3-f36cf2c98030@gmail.com>
In-Reply-To
<20190205195212.25550-3-avarab@gmail.com>
On 2/5/2019 2:52 PM, Ævar Arnfjörð Bjarmason wrote:
Show 23 quoted lines
> From: William Hubbs <williamh@gentoo.org>
> -const char *fmt_name(const char *name, const char *email)
> +const char *fmt_name(enum want_ident whose_ident)
>  {
> -	return fmt_ident(name, email, NULL, IDENT_STRICT | IDENT_NO_DATE);
> +	char *name = NULL;
> +	char *email = NULL;
> +
> +	switch (whose_ident) {
> +	case WANT_BLANK_IDENT:
> +		break;
> +	case WANT_AUTHOR_IDENT:
> +		name = getenv("GIT_AUTHOR_NAME");
> +		email = getenv("GIT_AUTHOR_EMAIL");
> +		break;
> +	case WANT_COMMITTER_IDENT:
> +		name = getenv("GIT_COMMITTER_NAME");
> +		email = getenv("GIT_COMMITTER_EMAIL");
> +		break;
> +	}
> +	return fmt_ident(name, email, whose_ident, NULL,
> +			IDENT_STRICT | IDENT_NO_DATE);
>  }
William and Ævar,

The "WANT_AUTHOR_IDENT" block of this switch statement does not appear to be hit by any tests, despite the tests included in this patch. My guess is that it is ignored because we have the following code in builtin/commit.c:

static void determine_author_info(struct strbuf *author_ident)
{
	char *name, *email, *date;
	struct ident_split author;
	name = xstrdup_or_null(getenv("GIT_AUTHOR_NAME"));
	email = xstrdup_or_null(getenv("GIT_AUTHOR_EMAIL"));
	date = xstrdup_or_null(getenv("GIT_AUTHOR_DATE"));
...

This is likely overriding the need to use fmt_name. Should we de-duplicate this use of the environment variable by using your new method at this spot in builtin/commit.c?

Thanks, -Stolee

Previous: William Hubbs
Message 23 of 23 in “config: allow giving separate author and committer”
  1. 0/1 config: allow giving separate author and committerWilliam Hubbs, Feb 4, 2019
  2. 1/1 config: allow giving separate author and committer identsWilliam Hubbs, Feb 4, 2019
  3. Johannes SchindelinFeb 5, 2019
  4. Junio C HamanoFeb 5, 2019
  5. 0/2 New {author,committer}.{name,email} configÆvar Arnfjörð Bjarmason, Feb 5, 2019
  6. 1/2 ident: test how GIT_* and user.{name,email} interactÆvar Arnfjörð Bjarmason, Feb 5, 2019
  7. 2/2 config: allow giving separate author and committer identsÆvar Arnfjörð Bjarmason, Feb 5, 2019
  8. Junio C HamanoFeb 5, 2019
  9. Ævar Arnfjörð BjarmasonFeb 5, 2019
  10. William HubbsFeb 6, 2019
  11. William HubbsFeb 6, 2019
  12. William HubbsFeb 6, 2019
  13. Junio C HamanoFeb 6, 2019
  14. William HubbsFeb 13, 2019
  15. Junio C HamanoFeb 13, 2019
  16. William HubbsFeb 14, 2019
  17. Ævar Arnfjörð BjarmasonFeb 6, 2019
  18. Ævar Arnfjörð BjarmasonFeb 6, 2019
  19. Jeff KingFeb 6, 2019
  20. William HubbsFeb 6, 2019
  21. Junio C HamanoFeb 6, 2019
  22. William HubbsFeb 6, 2019
  23. Derrick StoleeApr 15, 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.