diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-02-01 12:40:05 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-02-01 12:40:05 -0800 |
commit | a14daf8b9101225792341e4354699c5a2e30449a (patch) | |
tree | 49be522d86a83d3887925beb7d76459df7311d00 /ident.c | |
parent | 67d9c41c4a74619d81d9832efb25773126934852 (diff) | |
parent | dc342a25d1b48cb53448fe0e5dde578edce3122c (diff) | |
download | git-a14daf8b9101225792341e4354699c5a2e30449a.tar.gz |
Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname'
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
Diffstat (limited to 'ident.c')
-rw-r--r-- | ident.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; } |