]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase--interactive: move sequencer_add_exec_commands()
authorAlban Gruin <alban.gruin@gmail.com>
Tue, 5 Mar 2019 19:17:58 +0000 (20:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Mar 2019 00:17:57 +0000 (09:17 +0900)
As sequencer_add_exec_commands() 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 ffbe14cef5039e47ac1dee6f22d0a021eb2faa10..3bf1da69402dbfffe93ae6caa0c0de5d705a73f5 100644 (file)
@@ -13,6 +13,31 @@ static GIT_PATH_FUNC(path_state_dir, "rebase-merge/")
 static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto")
 static GIT_PATH_FUNC(path_interactive, "rebase-merge/interactive")
 
+static int add_exec_commands(struct string_list *commands)
+{
+       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);
+       }
+
+       todo_list_add_exec_commands(&todo_list, commands);
+       res = todo_list_write_to_file(the_repository, &todo_list,
+                                     todo_file, NULL, NULL, -1, 0);
+       todo_list_release(&todo_list);
+
+       if (res)
+               return error_errno(_("could not write '%s'."), todo_file);
+       return 0;
+}
+
 static int get_revision_ranges(const char *upstream, const char *onto,
                               const char **head_hash,
                               char **revisions, char **shortrevisions)
@@ -266,7 +291,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
                ret = rearrange_squash_in_todo_file(the_repository);
                break;
        case ADD_EXEC:
-               ret = sequencer_add_exec_commands(the_repository, &commands);
+               ret = add_exec_commands(&commands);
                break;
        default:
                BUG("invalid command '%d'", command);
index 1d5cd2fc27cfc405798ddbd0297ce6987648c180..280d9bcce7314a202a6d5158493cc77bfa1934e9 100644 (file)
@@ -4500,8 +4500,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
  * Add commands after pick and (series of) squash/fixup commands
  * in the todo list.
  */
-static void todo_list_add_exec_commands(struct todo_list *todo_list,
-                                       struct string_list *commands)
+void todo_list_add_exec_commands(struct todo_list *todo_list,
+                                struct string_list *commands)
 {
        struct strbuf *buf = &todo_list->buf;
        size_t base_offset = buf->len;
@@ -4567,30 +4567,6 @@ static void todo_list_add_exec_commands(struct todo_list *todo_list,
        todo_list->alloc = alloc;
 }
 
-int sequencer_add_exec_commands(struct repository *r,
-                               struct string_list *commands)
-{
-       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);
-       }
-
-       todo_list_add_exec_commands(&todo_list, commands);
-       res = todo_list_write_to_file(r, &todo_list, todo_file, NULL, NULL, -1, 0);
-       todo_list_release(&todo_list);
-
-       if (res)
-               return error_errno(_("could not write '%s'."), todo_file);
-       return 0;
-}
-
 static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_list,
                                struct strbuf *buf, int num, unsigned flags)
 {
index 7029b39cd690fdd58f06bc842106851aa4e9166b..0c4b7c80f808ddb4a03514f99cecdec6166d46f7 100644 (file)
@@ -145,9 +145,9 @@ 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 sequencer_add_exec_commands(struct repository *r,
-                               struct string_list *commands);
 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);
 int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
                    const char *shortrevisions, const char *onto_name,