Skip to content

Commit 7587149

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f66c83 commit 7587149

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sequencer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ static void print_advice(int show_hint, struct replay_opts *opts)
234234
}
235235
}
236236

237-
static int write_message(struct strbuf *msgbuf, const char *filename)
237+
static int write_message(const void *buf, size_t len, const char *filename)
238238
{
239239
static struct lock_file msg_file;
240240

241241
int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0);
242242
if (msg_fd < 0)
243243
return error_errno(_("Could not lock '%s'"), filename);
244-
if (write_in_full(msg_fd, msgbuf->buf, msgbuf->len) < 0) {
244+
if (write_in_full(msg_fd, buf, len) < 0) {
245245
rollback_lock_file(&msg_file);
246246
return error_errno(_("Could not write to '%s'"), filename);
247247
}
@@ -747,12 +747,14 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
747747
head, &msgbuf, opts);
748748
if (res < 0)
749749
return res;
750-
res |= write_message(&msgbuf, git_path_merge_msg());
750+
res |= write_message(msgbuf.buf, msgbuf.len,
751+
git_path_merge_msg());
751752
} else {
752753
struct commit_list *common = NULL;
753754
struct commit_list *remotes = NULL;
754755

755-
res = write_message(&msgbuf, git_path_merge_msg());
756+
res = write_message(msgbuf.buf, msgbuf.len,
757+
git_path_merge_msg());
756758

757759
commit_list_insert(base, &common);
758760
commit_list_insert(next, &remotes);

0 commit comments

Comments
 (0)