Skip to content

Commit

Permalink
Clean up trailing whitespace when pretty-printing commits
Browse files Browse the repository at this point in the history
Partly because we've messed up and now have some commits with trailing
whitespace, but partly because this also just simplifies the code, let's
remove trailing whitespace from the end when pretty-printing commits.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Apr 15, 2006
1 parent cad1ed9 commit 40c2fe0
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,11 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
if (fmt == CMIT_FMT_ONELINE)
break;
}
if (fmt == CMIT_FMT_ONELINE) {
/* We do not want the terminating newline */
if (buf[offset - 1] == '\n')
offset--;
}
else {
/* Make sure there is an EOLN */
if (buf[offset - 1] != '\n')
buf[offset++] = '\n';
}
while (offset && isspace(buf[offset-1]))
offset--;
/* Make sure there is an EOLN for the non-oneline case */
if (fmt != CMIT_FMT_ONELINE)
buf[offset++] = '\n';
buf[offset] = '\0';
return offset;
}
Expand Down

0 comments on commit 40c2fe0

Please sign in to comment.