summaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-02-04 18:04:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-04 18:04:26 (GMT)
commit7f3d409cd18e74c1d3adf892dce70a2d02d0797a (patch)
tree6c957c196edad902d72e28861f4b2be9d6616b7a /ident.c
parent3d00a5c148ee5611fc21de6d20f5f82602a75c5f (diff)
parentdc342a25d1b48cb53448fe0e5dde578edce3122c (diff)
downloadgit-7f3d409cd18e74c1d3adf892dce70a2d02d0797a.zip
git-7f3d409cd18e74c1d3adf892dce70a2d02d0797a.tar.gz
git-7f3d409cd18e74c1d3adf892dce70a2d02d0797a.tar.bz2
Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname' into maint
We used to stuff "user@" and then append what we read from /etc/mailname to come up with a default e-mail ident, but a bug lost the "user@" part. * jn/do-not-drop-username-when-reading-from-etc-mailname: ident: do not drop username when reading from /etc/mailname
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ident.c b/ident.c
index ac9672f..1c123e6 100644
--- a/ident.c
+++ b/ident.c
@@ -46,6 +46,7 @@ static void copy_gecos(const struct passwd *w, struct strbuf *name)
static int add_mailname_host(struct strbuf *buf)
{
FILE *mailname;
+ struct strbuf mailnamebuf = STRBUF_INIT;
mailname = fopen("/etc/mailname", "r");
if (!mailname) {
@@ -54,14 +55,17 @@ static int add_mailname_host(struct strbuf *buf)
strerror(errno));
return -1;
}
- if (strbuf_getline(buf, mailname, '\n') == EOF) {
+ if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) {
if (ferror(mailname))
warning("cannot read /etc/mailname: %s",
strerror(errno));
+ strbuf_release(&mailnamebuf);
fclose(mailname);
return -1;
}
/* success! */
+ strbuf_addbuf(buf, &mailnamebuf);
+ strbuf_release(&mailnamebuf);
fclose(mailname);
return 0;
}