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

Re: [PATCH] Trick to force setup of a specific configured E-Mail per repo

From
Jeff King <peff@peff.net>
Date
Feb 3, 2016, 03:56 UTC
Message-ID
<20160203035648.GA20732@sigill.intra.peff.net>
In-Reply-To
<1454442861-4879-1-git-send-email-alonid@gmail.com>
On Tue, Feb 02, 2016 at 09:54:21PM +0200, Dan Aloni wrote:
Show 14 quoted lines
> Previously, before 5498c57cdd63, many people did the following:
> 
>    git config --global user.email "(none)"
> 
> This was helpful for people with more than one E-Mail address,
> targeting different E-Mail addresses for different clones.
> as it barred git from creating commit unless the user.email
> config was set in the per-clone config to the correct E-Mail
> address.
> 
> Now, since the original 'bug' was fixed, and practically every
> string is acceptable for user.email and user.name, it is best
> to reimplement the feature not as an exploit of a bug, but as
> an actual feature.

Just when I dare to think "somebody cannot possibly be relying on this arcane behavior", I am proven wrong. :)

The motivating case for your patch makes sense to me. In the implementation, though:

> +	if (strict && email && !strcmp(email, "(per-repo)")) {
> +		die("email is '(per-repo)', suggesting to set specific email "
> +		    "for the current repo");
> +	}

I find it disappointing that we go back to looking for magic sequences in the string. Could we perhaps do this more cleanly with a new config option? Like a "user.guessIdent" which defaults to true, but people can set to false. And without that, we do not do any automagic at all; we get the values from the GIT_COMMITTER_* environment or the user.{name,email} config variables, or we die().

I think that should allow your use case (and extend the same feature to user.name). It wouldn't work on older versions of git, but nor would your fix here (the only way to do that is to re-instate "(none)" as magical).

-Peff
Previous: Dan AloniNext: Duy Nguyen
Message 2 of 16 in “Trick to force setup of a specific configured E-Mail per repo”
  1. Trick to force setup of a specific configured E-Mail per repoDan Aloni, Feb 2, 2016
  2. Jeff KingFeb 3, 2016
  3. Duy NguyenFeb 3, 2016
  4. Jeff KingFeb 3, 2016
  5. Duy NguyenFeb 3, 2016
  6. Jeff KingFeb 3, 2016
  7. Junio C HamanoFeb 3, 2016
  8. Dan AloniFeb 3, 2016
  9. Eric SunshineFeb 3, 2016
  10. Add user.explicit boolean for when ident shouldn't be guessedDan Aloni, Feb 3, 2016
  11. Jeff KingFeb 4, 2016
  12. Jeff KingFeb 4, 2016
  13. Jeff KingFeb 4, 2016
  14. Dan AloniFeb 4, 2016
  15. Jeff KingFeb 4, 2016
  16. Dan AloniFeb 4, 2016

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.