Skip to content

Commit

Permalink
commit: fix pretty-printing of messages with "\nencoding "
Browse files Browse the repository at this point in the history
The function replace_encoding_header is given the whole
commit buffer, including the commit message. When looking
for the encoding header, if none was found in the header, it
would locate any line in the commit message matching
"\nencoding " and remove it.

Instead, we now make sure to search only to the end of the
header.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 28, 2007
1 parent 75c962c commit d0e50cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,18 @@ static char *get_header(const struct commit *commit, const char *key)
static char *replace_encoding_header(char *buf, char *encoding)
{
char *encoding_header = strstr(buf, "\nencoding ");
char *header_end = strstr(buf, "\n\n");
char *end_of_encoding_header;
int encoding_header_pos;
int encoding_header_len;
int new_len;
int need_len;
int buflen = strlen(buf) + 1;

if (!encoding_header)
return buf; /* should not happen but be defensive */
if (!header_end)
header_end = buf + buflen;
if (!encoding_header || encoding_header >= header_end)
return buf;
encoding_header++;
end_of_encoding_header = strchr(encoding_header, '\n');
if (!end_of_encoding_header)
Expand Down

0 comments on commit d0e50cb

Please sign in to comment.