summaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-07-08 09:12:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-07-08 16:47:29 (GMT)
commite78d5d49935373dabcc40c5e32aefe4956a70b97 (patch)
treef2d9307ea64ca0b233b42e61031244076db39adc /builtin/am.c
parente04d08a4b3373972717c805ae8e788219b873b2a (diff)
downloadgit-e78d5d49935373dabcc40c5e32aefe4956a70b97.zip
git-e78d5d49935373dabcc40c5e32aefe4956a70b97.tar.gz
git-e78d5d49935373dabcc40c5e32aefe4956a70b97.tar.bz2
use write_file_buf where applicable
There are several places where we open a file, write some content from a strbuf, and close it. These can be simplified with write_file_buf(). As a bonus, many of these did not catch write problems at close() time. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/builtin/am.c b/builtin/am.c
index a974223..5fdf5b4 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -402,13 +402,8 @@ static int read_commit_msg(struct am_state *state)
*/
static void write_commit_msg(const struct am_state *state)
{
- int fd;
const char *filename = am_path(state, "final-commit");
-
- fd = xopen(filename, O_WRONLY | O_CREAT, 0666);
- if (write_in_full(fd, state->msg, state->msg_len) < 0)
- die_errno(_("could not write to %s"), filename);
- close(fd);
+ write_file_buf(filename, state->msg, state->msg_len);
}
/**