diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2014-11-30 15:24:46 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-01 11:00:16 -0800 |
commit | 91aacda85a91192a9f66a0f175d739f77971412f (patch) | |
tree | beda5513b104a9f6a5295135250e4d70ee80d2ca /builtin/branch.c | |
parent | 316e53e68c7c4d89876524f7f010685ebfe7be1e (diff) | |
download | git-91aacda85a91192a9f66a0f175d739f77971412f.tar.gz |
use new wrapper write_file() for simple file writing
This fixes common problems in these code about error handling,
forgetting to close the file handle after fprintf() fails, or not
printing out the error string..
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/branch.c')
-rw-r--r-- | builtin/branch.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 3b79c5087f..1a475d8e94 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -764,7 +764,6 @@ static const char edit_description[] = "BRANCH_DESCRIPTION"; static int edit_branch_description(const char *branch_name) { - FILE *fp; int status; struct strbuf buf = STRBUF_INIT; struct strbuf name = STRBUF_INIT; @@ -777,8 +776,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); - fp = fopen(git_path(edit_description), "w"); - if ((fwrite(buf.buf, 1, buf.len, fp) < buf.len) || fclose(fp)) { + if (write_file(git_path(edit_description), 0, "%s", buf.buf)) { strbuf_release(&buf); return error(_("could not write branch description template: %s"), strerror(errno)); |