From d59805a43ddaf4bbd4528a2b7afa9809eca9b86b Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 15 Jun 2018 00:31:11 -0400 Subject: [PATCH 1/2] rebase --root: demonstrate a bug while amending root commit messages When splitting a repository, running `git rebase -i --root` to reword the initial commit, Git dies with BUG: sequencer.c:795: root commit without message. Signed-off-by: Todd Zullinger Signed-off-by: Johannes Schindelin --- t/t3404-rebase-interactive.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index c65826ddaced2f..ca94c688d23506 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -971,6 +971,15 @@ test_expect_success 'rebase -i --root fixup root commit' ' test 0 = $(git cat-file commit HEAD | grep -c ^parent\ ) ' +test_expect_failure 'rebase -i --root reword root commit' ' + test_when_finished "test_might_fail git rebase --abort" && + git checkout -b reword-root-branch master && + set_fake_editor && + FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \ + git rebase -i --root && + git show HEAD^ | grep "A changed" +' + test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' ' git reset --hard && git checkout conflict-branch && From 6f492ded5c4b9ee82501433d5a5227bc3e546c31 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 16 Jun 2018 21:00:38 +0200 Subject: [PATCH 2/2] rebase --root: fix amending root commit messages The code path that triggered that "BUG" really does not want to run without an explicit commit message. In the case where we want to amend a commit message, we have an *implicit* commit message, though: the one of the commit to amend. Therefore, this code path should not even be entered. Signed-off-by: Johannes Schindelin --- sequencer.c | 2 +- t/t3404-rebase-interactive.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sequencer.c b/sequencer.c index cca968043ea86c..4034c0461b5022 100644 --- a/sequencer.c +++ b/sequencer.c @@ -784,7 +784,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts, struct child_process cmd = CHILD_PROCESS_INIT; const char *value; - if (flags & CREATE_ROOT_COMMIT) { + if ((flags & CREATE_ROOT_COMMIT) && !(flags & AMEND_MSG)) { struct strbuf msg = STRBUF_INIT, script = STRBUF_INIT; const char *author = is_rebase_i(opts) ? read_author_ident(&script) : NULL; diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index ca94c688d23506..e500d7c3203cdf 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -971,7 +971,7 @@ test_expect_success 'rebase -i --root fixup root commit' ' test 0 = $(git cat-file commit HEAD | grep -c ^parent\ ) ' -test_expect_failure 'rebase -i --root reword root commit' ' +test_expect_success 'rebase -i --root reword root commit' ' test_when_finished "test_might_fail git rebase --abort" && git checkout -b reword-root-branch master && set_fake_editor &&