mirror of
https://github.com/git/git.git
synced 2024-10-30 05:47:53 +01:00
[PATCH] NUL terminate diff-tree header lines under -z.
Thomas Glanzmann noticed that diff-tree -z HEAD piped to diff-helper -z did not work. Since diff-helper -z expects NUL terminated lines, we should generate such. The output side of the diff-helper should always be using '\n' termination; earlier it used the same line_termination used for the input side, which was a mistake. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
046aa6440f
commit
5831b563a4
2 changed files with 13 additions and 2 deletions
|
@ -121,7 +121,7 @@ int main(int ac, const char **av) {
|
|||
if (status) {
|
||||
unrecognized:
|
||||
diff_flush(diff_output_style);
|
||||
printf("%s%c", sb1.buf, line_termination);
|
||||
printf("%s\n", sb1.buf);
|
||||
}
|
||||
}
|
||||
if (detect_rename)
|
||||
|
|
13
diff-tree.c
13
diff-tree.c
|
@ -277,7 +277,18 @@ static int call_diff_flush(void)
|
|||
if (nr_paths)
|
||||
diffcore_pathspec(paths);
|
||||
if (header) {
|
||||
printf("%s", header);
|
||||
if (diff_output_format == DIFF_FORMAT_MACHINE) {
|
||||
const char *ep, *cp;
|
||||
for (cp = header; *cp; cp = ep) {
|
||||
ep = strchr(cp, '\n');
|
||||
if (ep == 0) ep = cp + strlen(cp);
|
||||
printf("%.*s%c", ep-cp, cp, 0);
|
||||
if (*ep) ep++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("%s", header);
|
||||
}
|
||||
header = NULL;
|
||||
}
|
||||
diff_flush(diff_output_format);
|
||||
|
|
Loading…
Reference in a new issue