aboutsummaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-19 13:22:23 -0700
committerJunio C Hamano <gitster@pobox.com>2016-07-19 13:22:23 -0700
commit2b6456b8089e42232d80672525edbe411ba41549 (patch)
treeb80371caee35146d5cab5c415aac68bfafb1e014 /builtin/am.c
parent96e08010ee5b9d1dbfbcc8561fa69f972a415a38 (diff)
parent7eb6e10c9d7f43913615667740d1b22055cfba1f (diff)
downloadgit-2b6456b8089e42232d80672525edbe411ba41549.tar.gz
git-2b6456b8089e42232d80672525edbe411ba41549.tar.xz
Merge branch 'jk/write-file'
General code clean-up around a helper function to write a single-liner to a file. * jk/write-file: branch: use write_file_buf instead of write_file use write_file_buf where applicable write_file: add format attribute write_file: add pointer+len variant write_file: use xopen write_file: drop "gently" form branch: use non-gentle write_file for branch description am: ignore return value of write_file() config: fix bogus fd check when setting up default config
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/builtin/am.c b/builtin/am.c
index d5da5fe09..3ac244824 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -184,22 +184,22 @@ static inline const char *am_path(const struct am_state *state, const char *path
/**
* For convenience to call write_file()
*/
-static int write_state_text(const struct am_state *state,
- const char *name, const char *string)
+static void write_state_text(const struct am_state *state,
+ const char *name, const char *string)
{
- return write_file(am_path(state, name), "%s", string);
+ write_file(am_path(state, name), "%s", string);
}
-static int write_state_count(const struct am_state *state,
- const char *name, int value)
+static void write_state_count(const struct am_state *state,
+ const char *name, int value)
{
- return write_file(am_path(state, name), "%d", value);
+ write_file(am_path(state, name), "%d", value);
}
-static int write_state_bool(const struct am_state *state,
- const char *name, int value)
+static void write_state_bool(const struct am_state *state,
+ const char *name, int value)
{
- return write_state_text(state, name, value ? "t" : "f");
+ write_state_text(state, name, value ? "t" : "f");
}
/**
@@ -403,13 +403,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);
}
/**