sequencer: fix "rebase -i --root" corrupting author header timestamp
[gitweb.git] / t / t3404-rebase-interactive.sh
index 59c766540e5361af0eab19e33d1d61ef650bc72d..b72167ecd5068648d11de4b0279a27cd5a3eb84a 100755 (executable)
@@ -971,6 +971,16 @@ test_expect_success 'rebase -i --root fixup root commit' '
        test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
 '
 
+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" &&
+       test -z "$(git show -s --format=%p HEAD^)"
+'
+
 test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' '
        git reset --hard &&
        git checkout conflict-branch &&
@@ -1192,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' '
@@ -1204,10 +1214,6 @@ test_expect_success 'drop' '
        test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
 '
 
-cat >expect <<EOF
-Successfully rebased and updated refs/heads/missing-commit.
-EOF
-
 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
        test_config rebase.missingCommitsCheck ignore &&
        rebase_setup_and_clean missing-commit &&
@@ -1215,7 +1221,9 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
        FAKE_LINES="1 2 3 4" \
                git rebase -i --root 2>actual &&
        test D = $(git cat-file commit HEAD | sed -ne \$p) &&
-       test_i18ncmp expect actual
+       test_i18ngrep \
+               "Successfully rebased and updated refs/heads/missing-commit" \
+               actual
 '
 
 cat >expect <<EOF
@@ -1227,15 +1235,24 @@ To avoid this message, use "drop" to explicitly remove a commit.
 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
 The possible behaviours are: ignore, warn, error.
 
+Rebasing (1/4)
+Rebasing (2/4)
+Rebasing (3/4)
+Rebasing (4/4)
 Successfully rebased and updated refs/heads/missing-commit.
 EOF
 
+cr_to_nl () {
+       tr '\015' '\012'
+}
+
 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
        test_config rebase.missingCommitsCheck warn &&
        rebase_setup_and_clean missing-commit &&
        set_fake_editor &&
        FAKE_LINES="1 2 3 4" \
-               git rebase -i --root 2>actual &&
+               git rebase -i --root 2>actual.2 &&
+       cr_to_nl <actual.2 >actual &&
        test_i18ncmp expect actual &&
        test D = $(git cat-file commit HEAD | sed -ne \$p)
 '
@@ -1362,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