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

Re: [PATCH v2] ident: check /etc/mailname if email is unknown

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 3, 2011, 07:44 UTC
Message-ID
<20111003074433.GD17289@elie>
In-Reply-To
<4E895FBD.8020904@viscovery.net>
Johannes Sixt wrote:
> This warns on EACCES. Is that OK? (Just asking, I have no opinion.)

Good catch. I was worried for a moment: could some command call copy_email() in a loop, producing an annoyingly redundant stream of warnings?

Luckily setup_ident() checks if git_default_email has been set to save the trouble of computing it again. So the behavior is to warn exactly once when using a command that uses an ident string, which is still more often than ideal. It would be better to only warn if the permissions are creating an actual problem, so the user can (1) complain to the sysadmin and then (2) set an email address in ~/.gitconfig and move on.

We _could_ add parameters to setup_ident() to only warn if /etc/mailname was going to be used to produce the committer ident (or whichever ident is checked first). That would be confusing if GIT_COMMITTER_EMAIL is set and GIT_AUTHOR_EMAIL is not.

In the long term it would be nice to find a way to warn when the mailname we tried to retrieve was actually going to be used, but short of that, the least confusing behavior is to just not warn at all.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 ident.c |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
diff --git a/ident.c b/ident.c
index edb43144..6f5c885d 100644
--- a/ident.c
+++ b/ident.c
@@ -55,16 +55,9 @@ static int add_mailname_host(char *buf, size_t len)
 	FILE *mailname;
 
 	mailname = fopen("/etc/mailname", "r");
-	if (!mailname) {
-		if (errno != ENOENT)
-			warning("cannot open /etc/mailname: %s",
-				strerror(errno));
+	if (!mailname)
 		return -1;
-	}
 	if (!fgets(buf, len, mailname)) {
-		if (ferror(mailname))
-			warning("cannot read /etc/mailname: %s",
-				strerror(errno));
 		fclose(mailname);
 		return -1;
 	}
@@ -80,7 +73,6 @@ static void add_domainname(char *buf, size_t len)
 	const char *domainname;
 
 	if (gethostname(buf, len)) {
-		warning("cannot get host name: %s", strerror(errno));
 		strlcpy(buf, "(none)", len);
 		return;
 	}
-- 
1.7.7.rc1
Previous: Johannes SixtNext: Junio C Hamano
Message 5 of 11 in “ident: check /etc/mailname if email is unknown”
  1. ident: check /etc/mailname if email is unknownJonathan Nieder, Oct 3, 2011
  2. Junio C HamanoOct 3, 2011
  3. ident: check /etc/mailname if email is unknownJonathan Nieder, Oct 3, 2011
  4. Johannes SixtOct 3, 2011
  5. Jonathan NiederOct 3, 2011
  6. Junio C HamanoOct 3, 2011
  7. ident: do not retrieve default ident when unnecessaryJonathan Nieder, Oct 6, 2011
  8. Junio C HamanoOct 6, 2011
  9. Jonathan NiederOct 6, 2011
  10. Ian JacksonOct 3, 2011
  11. Junio C HamanoOct 3, 2011

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.