Skip to content

Commit

Permalink
Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname'
Browse files Browse the repository at this point in the history
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.  This is to fix it.

* jn/do-not-drop-username-when-reading-from-etc-mailname:
  ident: do not drop username when reading from /etc/mailname
  • Loading branch information
gitster committed Feb 1, 2013
2 parents 67d9c41 + dc342a2 commit a14daf8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit a14daf8

Please sign in to comment.