Subject: [PATCH v2 10/26] wrapper.c: allow to create an empty file with write_file()

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Tue, 16 Feb 2016 20:29:11 +0700

This is used later on to create empty .git/worktrees/xxx/locked when
"git worktree lock" is called with no reason given.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/wrapper.c b/wrapper.c
index 29a45d2..1dc1eff 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -666,7 +666,7 @@ static int write_file_v(const char *path, int fatal,
 	}
 	strbuf_vaddf(&sb, fmt, params);
 	strbuf_complete_line(&sb);
-	if (write_in_full(fd, sb.buf, sb.len) != sb.len) {
+	if (sb.len && write_in_full(fd, sb.buf, sb.len) != sb.len) {
 		int err = errno;
 		close(fd);
 		strbuf_release(&sb);
-- 
2.7.0.377.g4cd97dd