From: Jeff King Date: Mon, 21 May 2012 23:10:02 +0000 (-0400) Subject: ident: trim trailing newline from /etc/mailname X-Git-Tag: v1.7.11-rc1~15^2~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=132f4b6ccb470cb209167b7806c68805ba4dc600;p=git.git ident: trim trailing newline from /etc/mailname We use fgets to read the /etc/mailname file, which means we will typically end up with an extra newline in our git_default_email. Most of the time this doesn't matter, as fmt_ident will skip it as cruft, but there is one code path that accesses it directly (in http-push.c:lock_remote). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/ident.c b/ident.c index af92b2cd8..acb3a0843 100644 --- a/ident.c +++ b/ident.c @@ -74,6 +74,10 @@ static int add_mailname_host(char *buf, size_t len) } /* success! */ fclose(mailname); + + len = strlen(buf); + if (len && buf[len-1] == '\n') + buf[len-1] = '\0'; return 0; }