Skip to content

Commit

Permalink
ident: trim trailing newline from /etc/mailname
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 22, 2012
1 parent 2d4b4fc commit 132f4b6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ident.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 132f4b6

Please sign in to comment.