[PATCH 15/15] rebase--interactive: move transform_todo_file() to rebase--interactive.c
From: Alban Gruin <hidden>
Date: 2018-10-07 20:00:29
Subsystem:
the rest · Maintainer:
Linus Torvalds
As transform_todo_file() is only needed inside of rebase--interactive.c, it is moved there from sequencer.c. Signed-off-by: Alban Gruin <redacted> --- builtin/rebase--interactive.c | 21 +++++++++++++++++++++ sequencer.c | 21 --------------------- sequencer.h | 1 - 3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index 264e940b47..50b5c25402 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c@@ -33,6 +33,27 @@ static int edit_todo_file(unsigned flags) return 0; } +static int transform_todo_file(unsigned flags) +{ + const char *todo_file = rebase_path_todo(); + struct todo_list todo_list = TODO_LIST_INIT; + int res; + + if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0) + return error_errno(_("could not read '%s'."), todo_file); + + if (todo_list_parse_insn_buffer(todo_list.buf.buf, &todo_list)) { + todo_list_release(&todo_list); + return error(_("unusable todo list: '%s'"), todo_file); + } + + todo_list_transform(&todo_list, flags); + + res = write_message(todo_list.buf.buf, todo_list.buf.len, todo_file, 0); + todo_list_release(&todo_list); + return res; +} + static int get_revision_ranges(const char *upstream, const char *onto, const char **head_hash, char **revisions, char **shortrevisions)
diff --git a/sequencer.c b/sequencer.c
index 65bf251ba5..e837e52b64 100644
--- a/sequencer.c
+++ b/sequencer.c@@ -4485,27 +4485,6 @@ void todo_list_transform(struct todo_list *todo_list, unsigned flags) BUG("unusable todo list"); } -int transform_todo_file(unsigned flags) -{ - const char *todo_file = rebase_path_todo(); - struct todo_list todo_list = TODO_LIST_INIT; - int res; - - if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0) - return error(_("could not read '%s'."), todo_file); - - if (todo_list_parse_insn_buffer(todo_list.buf.buf, &todo_list)) { - todo_list_release(&todo_list); - return error(_("unusable todo list: '%s'"), todo_file); - } - - todo_list_transform(&todo_list, flags); - - res = write_message(todo_list.buf.buf, todo_list.buf.len, todo_file, 0); - todo_list_release(&todo_list); - return res; -} - int check_todo_list_from_file(void) { struct todo_list old_todo = TODO_LIST_INIT, new_todo = TODO_LIST_INIT;
diff --git a/sequencer.h b/sequencer.h
index fa84918c55..a4b0113206 100644
--- a/sequencer.h
+++ b/sequencer.h@@ -137,7 +137,6 @@ int sequencer_make_script(struct strbuf *out, int argc, const char **argv, unsigned flags); int sequencer_add_exec_commands(const char *command); -int transform_todo_file(unsigned flags); int check_todo_list_from_file(void); int complete_action(struct replay_opts *opts, unsigned flags, const char *shortrevisions, const char *onto_name,
--
2.19.1