rebase--interactive: move sequencer_add_exec_commands()
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>
Alban Gruin committed
Mar 5, 2019 at 20:17 UTC
1ba204de6924b171024638bb5f3f405a0e0946d0
3 files changed
+30
-29
builtin/rebase--interactive.c
+26
-1
@@ -13,6 +13,31 @@ static GIT_PATH_FUNC(path_state_dir, "rebase-merge/")
13
static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto")
14
static GIT_PATH_FUNC(path_interactive, "rebase-merge/interactive")
15
16
+static int add_exec_commands(struct string_list *commands)
17
+{
18
+ const char *todo_file = rebase_path_todo();
19
+ struct todo_list todo_list = TODO_LIST_INIT;
20
+ int res;
21
+
22
+ if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
23
+ return error_errno(_("could not read '%s'."), todo_file);
24
+
25
+ if (todo_list_parse_insn_buffer(the_repository, todo_list.buf.buf,
26
+ &todo_list)) {
27
+ todo_list_release(&todo_list);
28
+ return error(_("unusable todo list: '%s'"), todo_file);
29
+ }
30
+
31
+ todo_list_add_exec_commands(&todo_list, commands);
32
+ res = todo_list_write_to_file(the_repository, &todo_list,
33
+ todo_file, NULL, NULL, -1, 0);
34
+ todo_list_release(&todo_list);
35
+
36
+ if (res)
37
+ return error_errno(_("could not write '%s'."), todo_file);
38
+ return 0;
39
+}
40
+
41
static int get_revision_ranges(const char *upstream, const char *onto,
42
const char **head_hash,
43
char **revisions, char **shortrevisions)
@@ -266,7 +291,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
291
ret = rearrange_squash_in_todo_file(the_repository);
292
break;
293
case ADD_EXEC:
269
- ret = sequencer_add_exec_commands(the_repository, &commands);
294
+ ret = add_exec_commands(&commands);
295
break;
296
default:
297
BUG("invalid command '%d'", command);
sequencer.c
+2
-26
@@ -4500,8 +4500,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
4500
* Add commands after pick and (series of) squash/fixup commands
4501
* in the todo list.
4502
*/
4503
-static void todo_list_add_exec_commands(struct todo_list *todo_list,
4504
- struct string_list *commands)
4503
+void todo_list_add_exec_commands(struct todo_list *todo_list,
4504
+ struct string_list *commands)
4505
{
4506
struct strbuf *buf = &todo_list->buf;
4507
size_t base_offset = buf->len;
@@ -4567,30 +4567,6 @@ static void todo_list_add_exec_commands(struct todo_list *todo_list,
4567
todo_list->alloc = alloc;
4568
}
4569
4570
-int sequencer_add_exec_commands(struct repository *r,
4571
- struct string_list *commands)
4572
-{
4573
- const char *todo_file = rebase_path_todo();
4574
- struct todo_list todo_list = TODO_LIST_INIT;
4575
- int res;
4576
-
4577
- if (strbuf_read_file(&todo_list.buf, todo_file, 0) < 0)
4578
- return error_errno(_("could not read '%s'."), todo_file);
4579
-
4580
- if (todo_list_parse_insn_buffer(r, todo_list.buf.buf, &todo_list)) {
4581
- todo_list_release(&todo_list);
4582
- return error(_("unusable todo list: '%s'"), todo_file);
4583
- }
4584
-
4585
- todo_list_add_exec_commands(&todo_list, commands);
4586
- res = todo_list_write_to_file(r, &todo_list, todo_file, NULL, NULL, -1, 0);
4587
- todo_list_release(&todo_list);
4588
-
4589
- if (res)
4590
- return error_errno(_("could not write '%s'."), todo_file);
4591
- return 0;
4592
-}
4593
-
4570
static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_list,
4571
struct strbuf *buf, int num, unsigned flags)
4572
{
sequencer.h
+2
-2
@@ -145,9 +145,9 @@ int sequencer_remove_state(struct replay_opts *opts);
145
int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
146
const char **argv, unsigned flags);
147
148
-int sequencer_add_exec_commands(struct repository *r,
149
- struct string_list *commands);
148
int transform_todo_file(struct repository *r, unsigned flags);
149
+void todo_list_add_exec_commands(struct todo_list *todo_list,
150
+ struct string_list *commands);
151
int check_todo_list_from_file(struct repository *r);
152
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
153
const char *shortrevisions, const char *onto_name,