From: Jeff King Date: Fri, 8 Jul 2016 09:16:53 +0000 (-0400) Subject: branch: use write_file_buf instead of write_file X-Git-Tag: v2.10.0-rc0~102^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7eb6e10c9d7f43913615667740d1b22055cfba1f;p=thirdparty%2Fgit.git branch: use write_file_buf instead of write_file 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/branch.c b/builtin/branch.c index 15232c4a42..1d41251a9a 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);