Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2019-03-05 22:17:59 +0300
committerJunio C Hamano <gitster@pobox.com>2019-03-07 03:17:57 +0300
commit79d7e883bb69803daf4a6f44692cb8fc0eee5b24 (patch)
tree90d349927510530170bd2190ea2105ada8579a24 /builtin/rebase--interactive.c
parent1ba204de6924b171024638bb5f3f405a0e0946d0 (diff)
rebase--interactive: move rearrange_squash_in_todo_file()
As rearrange_squash_in_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, and the error handling is slightly improved. 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.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c
index 3bf1da6940..ab2c6fcd99 100644
--- a/builtin/rebase--interactive.c
+++ b/builtin/rebase--interactive.c
@@ -38,6 +38,32 @@ static int add_exec_commands(struct string_list *commands)
return 0;
}
+static int rearrange_squash_in_todo_file(void)
+{
+ const char *todo_file = rebase_path_todo();
+ struct todo_list todo_list = TODO_LIST_INIT;
+ int res = 0;
+
+ 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_rearrange_squash(&todo_list);
+ if (!res)
+ 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)
@@ -288,7 +314,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
ret = check_todo_list_from_file(the_repository);
break;
case REARRANGE_SQUASH:
- ret = rearrange_squash_in_todo_file(the_repository);
+ ret = rearrange_squash_in_todo_file();
break;
case ADD_EXEC:
ret = add_exec_commands(&commands);