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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 21, 2012 at 19:10 UTC
132f4b6ccb470cb209167b7806c68805ba4dc600
1 file changed
+4
ident.c
+4
@@ -74,6 +74,10 @@ static int add_mailname_host(char *buf, size_t len)
74
}
75
/* success! */
76
fclose(mailname);
77
+
78
+ len = strlen(buf);
79
+ if (len && buf[len-1] == '\n')
80
+ buf[len-1] = '\0';
81
return 0;
82
}
83