Imported Upstream version 2.17.0
[platform/upstream/git.git] / t / t3400-rebase.sh
index 80e0a95..72d9564 100755 (executable)
@@ -136,8 +136,8 @@ test_expect_success 'setup: recover' '
 test_expect_success 'Show verbose error when HEAD could not be detached' '
        >B &&
        test_must_fail git rebase topic 2>output.err >output.out &&
-       grep "The following untracked working tree files would be overwritten by checkout:" output.err &&
-       grep B output.err
+       test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" output.err &&
+       test_i18ngrep B output.err
 '
 rm -f B
 
@@ -169,6 +169,29 @@ test_expect_success 'default to common base in @{upstream}s reflog if no upstrea
        test_cmp expect actual
 '
 
+test_expect_success 'cherry-picked commits and fork-point work together' '
+       git checkout default-base &&
+       echo Amended >A &&
+       git commit -a --no-edit --amend &&
+       test_commit B B &&
+       test_commit new_B B "New B" &&
+       test_commit C C &&
+       git checkout default &&
+       git reset --hard default-base@{4} &&
+       test_commit D D &&
+       git cherry-pick -2 default-base^ &&
+       test_commit final_B B "Final B" &&
+       git rebase &&
+       echo Amended >expect &&
+       test_cmp A expect &&
+       echo "Final B" >expect &&
+       test_cmp B expect &&
+       echo C >expect &&
+       test_cmp C expect &&
+       echo D >expect &&
+       test_cmp D expect
+'
+
 test_expect_success 'rebase -q is quiet' '
        git checkout -b quiet topic &&
        git rebase -q master >output.out 2>&1 &&
@@ -232,4 +255,60 @@ test_expect_success 'rebase commit with an ancient timestamp' '
        grep "author .* 34567 +0600$" actual
 '
 
+test_expect_success 'rebase with "From " line in commit message' '
+       git checkout -b preserve-from master~1 &&
+       cat >From_.msg <<EOF &&
+Somebody embedded an mbox in a commit message
+
+This is from so-and-so:
+
+From a@b Mon Sep 17 00:00:00 2001
+From: John Doe <nobody@example.com>
+Date: Sat, 11 Nov 2017 00:00:00 +0000
+Subject: not this message
+
+something
+EOF
+       >From_ &&
+       git add From_ &&
+       git commit -F From_.msg &&
+       git rebase master &&
+       git log -1 --pretty=format:%B >out &&
+       test_cmp From_.msg out
+'
+
+test_expect_success 'rebase--am.sh and --show-current-patch' '
+       test_create_repo conflict-apply &&
+       (
+               cd conflict-apply &&
+               test_commit init &&
+               echo one >>init.t &&
+               git commit -a -m one &&
+               echo two >>init.t &&
+               git commit -a -m two &&
+               git tag two &&
+               test_must_fail git rebase --onto init HEAD^ &&
+               GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
+               grep "show.*$(git rev-parse two)" stderr
+       )
+'
+
+test_expect_success 'rebase--merge.sh and --show-current-patch' '
+       test_create_repo conflict-merge &&
+       (
+               cd conflict-merge &&
+               test_commit init &&
+               echo one >>init.t &&
+               git commit -a -m one &&
+               echo two >>init.t &&
+               git commit -a -m two &&
+               git tag two &&
+               test_must_fail git rebase --merge --onto init HEAD^ &&
+               git rebase --show-current-patch >actual.patch &&
+               GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
+               grep "show.*REBASE_HEAD" stderr &&
+               test "$(git rev-parse REBASE_HEAD)" = "$(git rev-parse two)"
+       )
+'
+
 test_done