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

[PATCH] Prefer $EMAIL over auto-generated user@hostname.

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jul 6, 2007, 15:03 UTC
Message-ID
<468E59B3.7080007@nrlssc.navy.mil>

This makes $EMAIL the second to last resort ahead of username@hostname rather than the last resort when GIT_AUTHOR_EMAIL or GIT_COMMITER_EMAIL and user.email are not set.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
Linus Torvalds wrote:
>If you want it to prefer $EMAIL, you'd need to change the initialization 
>of git_default_email, methinks.
How about this?
 ident.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ident.c b/ident.c
index 3d49608..dc13510 100644
--- a/ident.c
+++ b/ident.c
@@ -73,6 +73,7 @@ static void copy_email(const struct passwd *pw)
 static void setup_ident(void)
 {
 	struct passwd *pw = NULL;
+        char *email;
 
 	/* Get the name ("gecos") */
 	if (!git_default_name[0]) {
@@ -82,6 +83,9 @@ static void setup_ident(void)
 		copy_gecos(pw, git_default_name, sizeof(git_default_name));
 	}
 
+	if (!git_default_email[0] && (email = getenv("EMAIL")) != NULL)
+                strlcpy(git_default_email, email, sizeof(git_default_email));
+
 	if (!git_default_email[0]) {
 		if (!pw)
 			pw = getpwuid(getuid());
@@ -197,8 +201,6 @@ const char *fmt_ident(const char *name, const char *email,
 		name = git_default_name;
 	if (!email)
 		email = git_default_email;
-	if (!email)
-		email = getenv("EMAIL");
 
 	if (!*name) {
 		struct passwd *pw;
-- 
1.5.3.rc0.30.g114f-dirty
Next: Uwe Kleine-König
Message 1 of 9 in “Prefer $EMAIL over auto-generated user@hostname.”
  1. Prefer $EMAIL over auto-generated user@hostname.Brandon Casey, Jul 6, 2007
  2. Uwe Kleine-KönigJul 6, 2007
  3. Brandon CaseyJul 6, 2007
  4. Johannes SchindelinJul 6, 2007
  5. Brandon CaseyJul 6, 2007
  6. Alex RiesenJul 6, 2007
  7. Vincent HanquezJul 6, 2007
  8. Alex RiesenJul 6, 2007
  9. Alex RiesenJul 6, 2007

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.