diff options
author | Alban Gruin <alban.gruin@gmail.com> | 2019-03-05 20:18:05 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-03-07 09:17:57 +0900 |
commit | ed35d18841130fee0109cbe40b659275a3f78cc9 (patch) | |
tree | 528e12705e2e06abf5ed26d6309cbf2d504cdd79 /builtin/rebase--interactive.c | |
parent | sequencer: use edit_todo_list() in complete_action() (diff) | |
download | tgif-ed35d18841130fee0109cbe40b659275a3f78cc9.tar.xz |
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>
Diffstat (limited to 'builtin/rebase--interactive.c')
-rw-r--r-- | builtin/rebase--interactive.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c index b277239f21..4d9c1e62bb 100644 --- a/builtin/rebase--interactive.c +++ b/builtin/rebase--interactive.c @@ -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); |