[PATCH] ui-patch: Flush stdout after outputting data

John Keeping john at keeping.me.uk
Wed Jun 11 22:01:50 CEST 2014


Since the "html" functions use raw write(2) to STDIO_FILENO, we don't
notice problems with most pages, but raw patches write using printf(3).
This is fine if we're outputting straight to stdout since the buffers
are flushed on exit, but we close the cache output before this, so the
cached output ends up being truncated.

Make sure the buffers are flushed when we finish outputting a patch so
that we avoid this.

No other UIs use printf(3) so we do not need to worry about them.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 ui-patch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ui-patch.c b/ui-patch.c
index 6878a46..fc6c145 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -82,4 +82,6 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
 		log_tree_commit(&rev, commit);
 		printf("-- \ncgit %s\n\n", cgit_version);
 	}
+
+	fflush(stdout);
 }
-- 
2.0.0.rc4.417.gc642ced



More information about the CGit mailing list