From e7ffa38c6e726e8014b76297b06f78e008deb2d0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 24 Aug 2015 09:39:48 -0700 Subject: write_file_v(): do not leave incomplete line at the end All existing callers to this function use it to produce a text file or an empty file, and a new callsite that mimick them must end their payload with a LF. If they forget to do so, the resulting file will end with an incomplete line. Teach write_file_v() to complete the incomplete line, if exists, so that the callers do not have to. With this, the caller-side fix in builtin/am.c becomes unnecessary. Signed-off-by: Junio C Hamano --- wrapper.c | 1 + 1 file changed, 1 insertion(+) (limited to 'wrapper.c') diff --git a/wrapper.c b/wrapper.c index 8c8925b72..0e22d4381 100644 --- a/wrapper.c +++ b/wrapper.c @@ -632,6 +632,7 @@ static int write_file_v(const char *path, int fatal, return -1; } strbuf_vaddf(&sb, fmt, params); + strbuf_complete_line(&sb); if (write_in_full(fd, sb.buf, sb.len) != sb.len) { int err = errno; close(fd); -- cgit v1.2.1