aboutsummaryrefslogtreecommitdiff
path: root/ident.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-05-21 19:10:02 -0400
committerJunio C Hamano <gitster@pobox.com>2012-05-22 09:07:53 -0700
commit132f4b6ccb470cb209167b7806c68805ba4dc600 (patch)
tree730543873523cbc22f41f454944c94e69a929b5f /ident.c
parent2d4b4fcebdd4fb8c8cd2664b390e3bbb82370155 (diff)
downloadgit-132f4b6ccb470cb209167b7806c68805ba4dc600.tar.gz
git-132f4b6ccb470cb209167b7806c68805ba4dc600.tar.xz
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>
Diffstat (limited to 'ident.c')
-rw-r--r--ident.c4
1 files changed, 4 insertions, 0 deletions
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;
}