This adds the ability to check if commits were dropped when resuming a rebase (with `--continue') or when reloading the todo list after an `exec' command. Tests added previously should work now. Signed-off-by: Alban Gruin <alban.gruin@xxxxxxxxx> --- sequencer.c | 5 ++++- t/t3404-rebase-interactive.sh | 4 ++-- t/t3429-rebase-edit-todo.sh | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index 0638c92f12..d2c4459e7c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2360,7 +2360,6 @@ static int read_populate_todo(struct repository *r, struct stat st; const char *todo_file = get_todo_path(opts); int res; - strbuf_reset(&todo_list->buf); if (strbuf_read_file_or_whine(&todo_list->buf, todo_file) < 0) return -1; @@ -2378,6 +2377,10 @@ static int read_populate_todo(struct repository *r, return error(_("unusable instruction sheet: '%s'"), todo_file); } + res = todo_list_check_against_backup(r, todo_list); + if (res) + return -1; + if (!todo_list->nr && (!is_rebase_i(opts) || !file_exists(rebase_path_done()))) return error(_("no commits parsed.")); diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index f5c0a8d2bb..090a496bcc 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1373,7 +1373,7 @@ EOF tail -n 8 <expect >expect.2 -test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' ' test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && set_fake_editor && @@ -1405,7 +1405,7 @@ EOF tail -n 9 <expect >expect.2 -test_expect_failure 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' +test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' ' test_config rebase.missingCommitsCheck error && rebase_setup_and_clean missing-commit && set_fake_editor && diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index 2bb9fb65fa..79cd5657b3 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -50,7 +50,7 @@ Use 'git config rebase.missingCommitsCheck' to change the level of warnings. The possible behaviours are: ignore, warn, error. EOF -test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = warn' ' +test_expect_success 'rebase exec respects rebase.missingCommitsCheck = warn' ' test_config rebase.missingCommitsCheck warn && git reset --hard HEAD@{2} && git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 && @@ -59,7 +59,7 @@ test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = warn' ' test 5 = $(git cat-file commit HEAD | sed -ne \$p) ' -test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = error' ' +test_expect_success 'rebase exec respects rebase.missingCommitsCheck = error' ' test_config rebase.missingCommitsCheck error && git reset --hard HEAD@{2} && test_must_fail git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 && -- 2.22.0