summaryrefslogtreecommitdiff
path: root/rebase-interactive.c
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2020-01-28 21:12:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-28 22:13:41 (GMT)
commit1da5874c1b283862f8252a2f5f2f8d4afe86346a (patch)
treef90ec8e3e57d103a9b94f16dc3eb80c9339625a0 /rebase-interactive.c
parent26027625dd1ee358e2174a09d519252995d51662 (diff)
downloadgit-1da5874c1b283862f8252a2f5f2f8d4afe86346a.zip
git-1da5874c1b283862f8252a2f5f2f8d4afe86346a.tar.gz
git-1da5874c1b283862f8252a2f5f2f8d4afe86346a.tar.bz2
sequencer: move check_todo_list_from_file() to rebase-interactive.c
The message contained in `edit_todo_list_advice' (sequencer.c) is printed after the initial edit of the todo list if it can't be parsed or if commits were dropped. This is done either in complete_action() for `rebase -i', or in check_todo_list_from_file() for `rebase -p'. Since we want to add this check when editing the list, we also want to use this message from edit_todo_list() (rebase-interactive.c). To this end, check_todo_list_from_file() is moved to rebase-interactive.c, and `edit_todo_list_advice' is copied there. In the next commit, complete_action() will stop using it, and `edit_todo_list_advice' will be removed from sequencer.c. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rebase-interactive.c')
-rw-r--r--rebase-interactive.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 1259adc..45f29c2 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -6,6 +6,12 @@
#include "commit-slab.h"
#include "config.h"
+static const char edit_todo_list_advice[] =
+N_("You can fix this with 'git rebase --edit-todo' "
+"and then run 'git rebase --continue'.\n"
+"Or you can abort the rebase with 'git rebase"
+" --abort'.\n");
+
enum missing_commit_check_level {
MISSING_COMMIT_CHECK_IGNORE = 0,
MISSING_COMMIT_CHECK_WARN,
@@ -189,3 +195,32 @@ leave_check:
clear_commit_seen(&commit_seen);
return res;
}
+
+int check_todo_list_from_file(struct repository *r)
+{
+ struct todo_list old_todo = TODO_LIST_INIT, new_todo = TODO_LIST_INIT;
+ int res = 0;
+
+ if (strbuf_read_file(&new_todo.buf, rebase_path_todo(), 0) < 0) {
+ res = error(_("could not read '%s'."), rebase_path_todo());
+ goto out;
+ }
+
+ if (strbuf_read_file(&old_todo.buf, rebase_path_todo_backup(), 0) < 0) {
+ res = error(_("could not read '%s'."), rebase_path_todo_backup());
+ goto out;
+ }
+
+ res = todo_list_parse_insn_buffer(r, old_todo.buf.buf, &old_todo);
+ if (!res)
+ res = todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo);
+ if (!res)
+ res = todo_list_check(&old_todo, &new_todo);
+ if (res)
+ fprintf(stderr, _(edit_todo_list_advice));
+out:
+ todo_list_release(&old_todo);
+ todo_list_release(&new_todo);
+
+ return res;
+}