From: Jeff King Date: Fri, 08 Jul 2016 09:16:53 GMT Subject: [PATCH 9/8] branch: use write_file_buf instead of write_file Message-ID: <20160708091653.GA17072@sigill.intra.peff.net> In-Reply-To: <20160708090400.GA26594@sigill.intra.peff.net> If we already have a strbuf, then using write_file_buf is a little nicer to read (no wondering whether "%s" will eat your NULs), and it's more efficient (no extra formatting step). We don't care about the newline magic of write_file(), as we have our own multi-line content. Signed-off-by: Jeff King --- Almost forgot this one. I had originally converted to write_file_buf directly, but later reshuffled the patches to make the refactoring more clear. builtin/branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/branch.c b/builtin/branch.c index 15232c4..1d41251 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -618,7 +618,7 @@ static int edit_branch_description(const char *branch_name) " %s\n" "Lines starting with '%c' will be stripped.\n", branch_name, comment_line_char); - write_file(git_path(edit_description), "%s", buf.buf); + write_file_buf(git_path(edit_description), buf.buf, buf.len); strbuf_reset(&buf); if (launch_editor(git_path(edit_description), &buf, NULL)) { strbuf_release(&buf); -- 2.9.0.393.g704e522