Skip to content

Commit ed35d18

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1451d0f commit ed35d18

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

builtin/rebase--interactive.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,30 @@ static int rearrange_squash_in_todo_file(void)
6464
return 0;
6565
}
6666

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+
6791
static int edit_todo_file(unsigned flags)
6892
{
6993
const char *todo_file = rebase_path_todo();
@@ -330,7 +354,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
330354
}
331355
case SHORTEN_OIDS:
332356
case EXPAND_OIDS:
333-
ret = transform_todo_file(the_repository, flags);
357+
ret = transform_todo_file(flags);
334358
break;
335359
case CHECK_TODO_LIST:
336360
ret = check_todo_list_from_file(the_repository);

sequencer.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,29 +4632,6 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list,
46324632
return res;
46334633
}
46344634

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-
46584635
static const char edit_todo_list_advice[] =
46594636
N_("You can fix this with 'git rebase --edit-todo' "
46604637
"and then run 'git rebase --continue'.\n"

sequencer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int sequencer_remove_state(struct replay_opts *opts);
143143
int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
144144
const char **argv, unsigned flags);
145145

146-
int transform_todo_file(struct repository *r, unsigned flags);
147146
void todo_list_add_exec_commands(struct todo_list *todo_list,
148147
struct string_list *commands);
149148
int check_todo_list_from_file(struct repository *r);

0 commit comments

Comments
 (0)