diff mbox series

[v2,16/16] rebase--interactive: move transform_todo_file() to rebase--interactive.c

Message ID 20181027212930.9303-17-alban.gruin@gmail.com (mailing list archive)
State New, archived
Headers show
Series sequencer: refactor functions working on a todo_list | expand

Commit Message

Alban Gruin Oct. 27, 2018, 9:29 p.m. UTC
As transform_todo_file() is only needed inside of rebase--interactive.c,
it is moved there from sequencer.c.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 builtin/rebase--interactive.c | 20 ++++++++++++++++++++
 sequencer.c                   | 20 --------------------
 sequencer.h                   |  1 -
 3 files changed, 20 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index 0f83422aa0..28e6947ecb 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -34,6 +34,26 @@  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);
+	}
+
+	res = todo_list_write_to_file(&todo_list, todo_file,
+				      NULL, NULL, 0, 0, -1, flags);
+	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 3069d4c6a2..a1b81bd544 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4344,26 +4344,6 @@  int todo_list_write_to_file(struct todo_list *todo_list, const char *file,
 	return res;
 }
 
-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);
-	}
-
-	res = todo_list_write_to_file(&todo_list, todo_file,
-				      NULL, NULL, 0, 0, -1, flags);
-	todo_list_release(&todo_list);
-	return res;
-}
-
 static const char edit_todo_list_advice[] =
 N_("You can fix this with 'git rebase --edit-todo' "
 "and then run 'git rebase --continue'.\n"
diff --git a/sequencer.h b/sequencer.h
index 6a1a23541f..d35ca61d5d 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -134,7 +134,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,