From: Jonathan Nieder <jrnieder@gmail.com>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Matt Kraai <kraai@ftbfs.org>,
Gerrit Pape <pape@smarden.org>,
Ian Jackson <ijackson@chiark.greenend.org.uk>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2] ident: check /etc/mailname if email is unknown
Date: Mon, 3 Oct 2011 02:44:34 -0500 [thread overview]
Message-ID: <20111003074433.GD17289@elie> (raw)
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
next prev parent reply other threads:[~2011-10-03 7:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-03 4:57 [PATCH/RFC] ident: check /etc/mailname if email is unknown Jonathan Nieder
2011-10-03 5:30 ` Junio C Hamano
2011-10-03 6:16 ` [PATCH v2] " Jonathan Nieder
2011-10-03 7:09 ` Johannes Sixt
2011-10-03 7:44 ` Jonathan Nieder [this message]
2011-10-03 19:13 ` Junio C Hamano
2011-10-06 17:17 ` [PATCH/RFC jn/ident-from-etc-mailname] ident: do not retrieve default ident when unnecessary Jonathan Nieder
2011-10-06 18:19 ` Junio C Hamano
2011-10-06 18:48 ` Jonathan Nieder
2011-10-03 11:32 ` [PATCH v2] ident: check /etc/mailname if email is unknown Ian Jackson
2011-10-03 19:15 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111003074433.GD17289@elie \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ijackson@chiark.greenend.org.uk \
--cc=j.sixt@viscovery.net \
--cc=kraai@ftbfs.org \
--cc=pape@smarden.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).