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>
This commit is contained in:
parent
cad1ed9535
commit
40c2fe003c
15
commit.c
15
commit.c
@ -557,16 +557,11 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit
|
|||||||
if (fmt == CMIT_FMT_ONELINE)
|
if (fmt == CMIT_FMT_ONELINE)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fmt == CMIT_FMT_ONELINE) {
|
while (offset && isspace(buf[offset-1]))
|
||||||
/* We do not want the terminating newline */
|
offset--;
|
||||||
if (buf[offset - 1] == '\n')
|
/* Make sure there is an EOLN for the non-oneline case */
|
||||||
offset--;
|
if (fmt != CMIT_FMT_ONELINE)
|
||||||
}
|
buf[offset++] = '\n';
|
||||||
else {
|
|
||||||
/* Make sure there is an EOLN */
|
|
||||||
if (buf[offset - 1] != '\n')
|
|
||||||
buf[offset++] = '\n';
|
|
||||||
}
|
|
||||||
buf[offset] = '\0';
|
buf[offset] = '\0';
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user