rebase--interactive: move transform_todo_file()
authorAlban Gruin <alban.gruin@gmail.com>
Tue, 5 Mar 2019 19:18:05 +0000 (20:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Mar 2019 00:17:57 +0000 (09:17 +0900)
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>
builtin/rebase--interactive.c
sequencer.c
sequencer.h
index b277239f21444f804e17a68845a859d3232ed69f..4d9c1e62bbb689ecc4e3c51f058774bfb24af0ef 100644 (file)
@@ -64,6 +64,30 @@ static int rearrange_squash_in_todo_file(void)
        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(the_repository, 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(the_repository, &todo_list, todo_file,
+                                     NULL, NULL, -1, flags);
+       todo_list_release(&todo_list);
+
+       if (res)
+               return error_errno(_("could not write '%s'."), todo_file);
+       return 0;
+}
+
 static int edit_todo_file(unsigned flags)
 {
        const char *todo_file = rebase_path_todo();
@@ -330,7 +354,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
        }
        case SHORTEN_OIDS:
        case EXPAND_OIDS:
-               ret = transform_todo_file(the_repository, flags);
+               ret = transform_todo_file(flags);
                break;
        case CHECK_TODO_LIST:
                ret = check_todo_list_from_file(the_repository);
index c56c3add1a7c5e800543a6cdea71c1457d36bdc6..2a0fcb1cce19494723b9327e6f3b96b98cafe635 100644 (file)
@@ -4632,29 +4632,6 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
        return res;
 }
 
-int transform_todo_file(struct repository *r, 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(r, 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(r, &todo_list, todo_file,
-                                     NULL, NULL, -1, flags);
-       todo_list_release(&todo_list);
-
-       if (res)
-               return error_errno(_("could not write '%s'."), todo_file);
-       return 0;
-}
-
 static const char edit_todo_list_advice[] =
 N_("You can fix this with 'git rebase --edit-todo' "
 "and then run 'git rebase --continue'.\n"
index 195891a2670ca446a70ce83b3d95e3e58a9cd389..7cca49eff2f02222dc64012d0505a5d4af4d162a 100644 (file)
@@ -143,7 +143,6 @@ int sequencer_remove_state(struct replay_opts *opts);
 int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
                          const char **argv, unsigned flags);
 
-int transform_todo_file(struct repository *r, unsigned flags);
 void todo_list_add_exec_commands(struct todo_list *todo_list,
                                 struct string_list *commands);
 int check_todo_list_from_file(struct repository *r);