aboutsummaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-04-14 21:20:51 -0700
committerJunio C Hamano <junkio@cox.net>2006-04-14 21:46:08 -0700
commit40c2fe003ce2af3ec522f239be274fd1a27422f6 (patch)
treec59e926805f50a680b4985550c8b389c0e24faaa /commit.c
parentcad1ed953513c3ef099d524746bb737c2be7b701 (diff)
downloadgit-40c2fe003ce2af3ec522f239be274fd1a27422f6.tar.gz
git-40c2fe003ce2af3ec522f239be274fd1a27422f6.tar.xz
Clean up trailing whitespace when pretty-printing commits
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>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/commit.c b/commit.c
index c7bb8dba6..ca2557450 100644
--- a/commit.c
+++ b/commit.c
@@ -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;
}