diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2016-10-21 14:26:05 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-21 09:32:35 -0700 |
commit | 75871495e9e0012604861752d082715d9444333d (patch) | |
tree | 998955ff2dd10e96b8aab5c21b75e1206f1afe79 | |
parent | sequencer: roll back lock file if write_message() failed (diff) | |
download | tgif-75871495e9e0012604861752d082715d9444333d.tar.xz |
sequencer: refactor write_message() to take a pointer/length
Previously, we required an strbuf. But that limits the use case too much.
In the upcoming patch series (for which the current patch series prepares
the sequencer), we will want to write content to a file for which we have
a pointer and a length, not an strbuf.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | sequencer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sequencer.c b/sequencer.c index 9fced42dff..300952fc16 100644 --- a/sequencer.c +++ b/sequencer.c @@ -234,14 +234,14 @@ static void print_advice(int show_hint, struct replay_opts *opts) } } -static int write_message(struct strbuf *msgbuf, const char *filename) +static int write_message(const void *buf, size_t len, const char *filename) { static struct lock_file msg_file; int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0); if (msg_fd < 0) return error_errno(_("Could not lock '%s'"), filename); - if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0) { + if (write_in_full(msg_fd, buf, len) < 0) { rollback_lock_file(&msg_file); return error_errno(_("Could not write to '%s'"), filename); } @@ -747,12 +747,14 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, head, &msgbuf, opts); if (res < 0) return res; - res |= write_message(&msgbuf, git_path_merge_msg()); + res |= write_message(msgbuf.buf, msgbuf.len, + git_path_merge_msg()); } else { struct commit_list *common = NULL; struct commit_list *remotes = NULL; - res = write_message(&msgbuf, git_path_merge_msg()); + res = write_message(msgbuf.buf, msgbuf.len, + git_path_merge_msg()); commit_list_insert(base, &common); commit_list_insert(next, &remotes); |