rebase--interactive: move transform_todo_file()

As transform_todo_file() is only needed inside of rebase--interactive.c for `rebase -p', it is moved there from sequencer.c. The parameter r (repository) is dropped along the way. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alban Gruin committed Mar 5, 2019 at 20:18 UTC ed35d18841130fee0109cbe40b659275a3f78cc9
3 files changed +25 -25
builtin/rebase--interactive.c
+25 -1
@@ -64,6 +64,30 @@ static int rearrange_squash_in_todo_file(void)
64 return 0;
65 }
66
67 +static int transform_todo_file(unsigned flags)
68 +{
69 + const char *todo_file = rebase_path_todo();
70 + struct todo_list todo_list = TODO_LIST_INIT;
71 + int res;
72 +
73 + if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
74 + return error_errno(_("could not read '%s'."), todo_file);
75 +
76 + if (todo_list_parse_insn_buffer(the_repository, todo_list.buf.buf,
77 + &todo_list)) {
78 + todo_list_release(&todo_list);
79 + return error(_("unusable todo list: '%s'"), todo_file);
80 + }
81 +
82 + res = todo_list_write_to_file(the_repository, &todo_list, todo_file,
83 + NULL, NULL, -1, flags);
84 + todo_list_release(&todo_list);
85 +
86 + if (res)
87 + return error_errno(_("could not write '%s'."), todo_file);
88 + return 0;
89 +}
90 +
91 static int edit_todo_file(unsigned flags)
92 {
93 const char *todo_file = rebase_path_todo();
@@ -330,7 +354,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
354 }
355 case SHORTEN_OIDS:
356 case EXPAND_OIDS:
333 - ret = transform_todo_file(the_repository, flags);
357 + ret = transform_todo_file(flags);
358 break;
359 case CHECK_TODO_LIST:
360 ret = check_todo_list_from_file(the_repository);
sequencer.c
-23
@@ -4632,29 +4632,6 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
4632 return res;
4633 }
4634
4635 -int transform_todo_file(struct repository *r, unsigned flags)
4636 -{
4637 - const char *todo_file = rebase_path_todo();
4638 - struct todo_list todo_list = TODO_LIST_INIT;
4639 - int res;
4640 -
4641 - if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
4642 - return error_errno(_("could not read '%s'."), todo_file);
4643 -
4644 - if (todo_list_parse_insn_buffer(r, todo_list.buf.buf, &todo_list)) {
4645 - todo_list_release(&todo_list);
4646 - return error(_("unusable todo list: '%s'"), todo_file);
4647 - }
4648 -
4649 - res = todo_list_write_to_file(r, &todo_list, todo_file,
4650 - NULL, NULL, -1, flags);
4651 - todo_list_release(&todo_list);
4652 -
4653 - if (res)
4654 - return error_errno(_("could not write '%s'."), todo_file);
4655 - return 0;
4656 -}
4657 -
4635 static const char edit_todo_list_advice[] =
4636 N_("You can fix this with 'git rebase --edit-todo' "
4637 "and then run 'git rebase --continue'.\n"
sequencer.h
-1
@@ -143,7 +143,6 @@ int sequencer_remove_state(struct replay_opts *opts);
143 int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
144 const char **argv, unsigned flags);
145
146 -int transform_todo_file(struct repository *r, unsigned flags);
146 void todo_list_add_exec_commands(struct todo_list *todo_list,
147 struct string_list *commands);
148 int check_todo_list_from_file(struct repository *r);