Imported Upstream version 2.12.1
[platform/upstream/git.git] / t / t3404-rebase-interactive.sh
index 66348f1..e2f18d1 100755 (executable)
@@ -60,7 +60,7 @@ test_expect_success 'setup' '
        test_commit P fileP
 '
 
-# "exec" commands are ran with the user shell by default, but this may
+# "exec" commands are run with the user shell by default, but this may
 # be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
 # to create a file. Unsetting SHELL avoids such non-portable behavior
 # in tests. It must be exported for it to take effect where needed.
@@ -219,9 +219,9 @@ test_expect_success 'abort with error when new base cannot be checked out' '
        git commit -m "remove file in base" &&
        set_fake_editor &&
        test_must_fail git rebase -i master > output 2>&1 &&
-       grep "The following untracked working tree files would be overwritten by checkout:" \
+       test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
                output &&
-       grep "file1" output &&
+       test_i18ngrep "file1" output &&
        test_path_is_missing .git/rebase-merge &&
        git reset --hard HEAD^
 '
@@ -237,6 +237,22 @@ test_expect_success 'retain authorship' '
        git show HEAD | grep "^Author: Twerp Snog"
 '
 
+test_expect_success 'retain authorship w/ conflicts' '
+       git reset --hard twerp &&
+       test_commit a conflict a conflict-a &&
+       git reset --hard twerp &&
+       GIT_AUTHOR_NAME=AttributeMe \
+       test_commit b conflict b conflict-b &&
+       set_fake_editor &&
+       test_must_fail git rebase -i conflict-a &&
+       echo resolved >conflict &&
+       git add conflict &&
+       git rebase --continue &&
+       test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) &&
+       git show >out &&
+       grep AttributeMe out
+'
+
 test_expect_success 'squash' '
        git reset --hard twerp &&
        echo B > file7 &&
@@ -540,7 +556,7 @@ test_expect_success 'clean error after failed "exec"' '
        echo "edited again" > file7 &&
        git add file7 &&
        test_must_fail git rebase --continue 2>error &&
-       grep "You have staged changes in your working tree." error
+       test_i18ngrep "You have staged changes in your working tree." error
 '
 
 test_expect_success 'rebase a detached HEAD' '
@@ -976,6 +992,17 @@ test_expect_success 'rebase -i respects core.commentchar' '
        test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
 
+test_expect_success 'rebase -i respects core.commentchar=auto' '
+       test_config core.commentchar auto &&
+       write_script copy-edit-script.sh <<-\EOF &&
+       cp "$1" edit-script
+       EOF
+       test_set_editor "$(pwd)/copy-edit-script.sh" &&
+       test_when_finished "git rebase --abort || :" &&
+       git rebase -i HEAD^ &&
+       test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
+'
+
 test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
        test_when_finished "git branch -D torebase" &&
        git checkout -b torebase branch1 &&
@@ -1060,7 +1087,7 @@ test_expect_success 'todo count' '
        EOF
        test_set_editor "$(pwd)/dump-raw.sh" &&
        git rebase -i HEAD~4 >actual &&
-       grep "^# Rebase ..* onto ..* ([0-9]" actual
+       test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
 '
 
 test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
@@ -1160,7 +1187,7 @@ 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_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 cat >expect <<EOF
@@ -1181,7 +1208,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
        set_fake_editor &&
        FAKE_LINES="1 2 3 4" \
                git rebase -i --root 2>actual &&
-       test_cmp expect actual &&
+       test_i18ncmp expect actual &&
        test D = $(git cat-file commit HEAD | sed -ne \$p)
 '
 
@@ -1195,7 +1222,7 @@ 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.
 
-You can fix this with 'git rebase --edit-todo'.
+You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
 Or you can abort the rebase with 'git rebase --abort'.
 EOF
 
@@ -1205,7 +1232,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
        set_fake_editor &&
        test_must_fail env FAKE_LINES="1 2 4" \
                git rebase -i --root 2>actual &&
-       test_cmp expect actual &&
+       test_i18ncmp expect actual &&
        cp .git/rebase-merge/git-rebase-todo.backup \
                .git/rebase-merge/git-rebase-todo &&
        FAKE_LINES="1 2 drop 3 4 drop 5" \
@@ -1219,7 +1246,7 @@ cat >expect <<EOF
 Warning: the command isn't recognized in the following line:
  - badcmd $(git rev-list --oneline -1 master~1)
 
-You can fix this with 'git rebase --edit-todo'.
+You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
 Or you can abort the rebase with 'git rebase --abort'.
 EOF
 
@@ -1228,7 +1255,7 @@ test_expect_success 'static check of bad command' '
        set_fake_editor &&
        test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
                git rebase -i --root 2>actual &&
-       test_cmp expect actual &&
+       test_i18ncmp expect actual &&
        FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
        git rebase --continue &&
        test E = $(git cat-file commit HEAD | sed -ne \$p) &&
@@ -1254,7 +1281,7 @@ cat >expect <<EOF
 Warning: the SHA-1 is missing or isn't a commit in the following line:
  - edit XXXXXXX False commit
 
-You can fix this with 'git rebase --edit-todo'.
+You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
 Or you can abort the rebase with 'git rebase --abort'.
 EOF
 
@@ -1263,7 +1290,7 @@ test_expect_success 'static check of bad SHA-1' '
        set_fake_editor &&
        test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
                git rebase -i --root 2>actual &&
-       test_cmp expect actual &&
+       test_i18ncmp expect actual &&
        FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
        git rebase --continue &&
        test E = $(git cat-file commit HEAD | sed -ne \$p)
@@ -1281,4 +1308,12 @@ test_expect_success 'editor saves as CR/LF' '
        )
 '
 
+SQ="'"
+test_expect_success 'rebase -i --gpg-sign=<key-id>' '
+       set_fake_editor &&
+       FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
+               >out 2>err &&
+       test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
+'
+
 test_done