sequencer: fix "rebase -i --root" corrupting author header timestamp
[gitweb.git] / t / t3404-rebase-interactive.sh
index ca94c688d235064cf1bd50b5cf1b7c760804d9d8..b72167ecd5068648d11de4b0279a27cd5a3eb84a 100755 (executable)
@@ -971,13 +971,14 @@ 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 &&
        FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
        git rebase -i --root &&
-       git show HEAD^ | grep "A changed"
+       git show HEAD^ | grep "A changed" &&
+       test -z "$(git show -s --format=%p HEAD^)"
 '
 
 test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' '
@@ -1201,7 +1202,7 @@ rebase_setup_and_clean () {
                test_might_fail git branch -D $1 &&
                test_might_fail git rebase --abort
        " &&
-       git checkout -b $1 master
+       git checkout -b $1 ${2:-master}
 }
 
 test_expect_success 'drop' '
@@ -1378,4 +1379,12 @@ test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
        test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
 '
 
+test_expect_success 'valid author header after --root swap' '
+       rebase_setup_and_clean author-header no-conflict-branch &&
+       set_fake_editor &&
+       FAKE_LINES="2 1" git rebase -i --root &&
+       git cat-file commit HEAD^ >out &&
+       grep "^author ..*> [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$" out
+'
+
 test_done