]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: add more regression tests for console output
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Mon, 19 Jun 2017 17:56:05 +0000 (18:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Jun 2017 18:20:39 +0000 (11:20 -0700)
Check the console output when using --autostash and the stash does not
apply is what we expect. The test is quite strict but should catch any
changes to the console output from the various rebase flavors.

Thanks-to: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3420-rebase-autostash.sh

index 827ea7f8b4e28e7c7ae886c45883d21f26455226..6826c38cbde39d5fb0e1f73e1abf0c877b0c4f78 100755 (executable)
@@ -88,6 +88,67 @@ create_expected_success_merge () {
        EOF
 }
 
+create_expected_failure_am () {
+       cat >expected <<-EOF
+       $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
+       HEAD is now at $(git rev-parse --short feature-branch) third commit
+       First, rewinding head to replay your work on top of it...
+       Applying: second commit
+       Applying: third commit
+       Applying autostash resulted in conflicts.
+       Your changes are safe in the stash.
+       You can run "git stash pop" or "git stash drop" at any time.
+       EOF
+}
+
+create_expected_failure_interactive () {
+       q_to_cr >expected <<-EOF
+       $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
+       HEAD is now at $(git rev-parse --short feature-branch) third commit
+       Rebasing (1/2)QRebasing (2/2)QApplying autostash resulted in conflicts.
+       Your changes are safe in the stash.
+       You can run "git stash pop" or "git stash drop" at any time.
+       Successfully rebased and updated refs/heads/rebased-feature-branch.
+       EOF
+}
+
+create_expected_failure_merge () {
+       cat >expected <<-EOF
+       $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual)
+       HEAD is now at $(git rev-parse --short feature-branch) third commit
+       First, rewinding head to replay your work on top of it...
+       Merging unrelated-onto-branch with HEAD~1
+       Merging:
+       $(git rev-parse --short unrelated-onto-branch) unrelated commit
+       $(git rev-parse --short feature-branch^) second commit
+       found 1 common ancestor:
+       $(git rev-parse --short feature-branch~2) initial commit
+       [detached HEAD $(git rev-parse --short rebased-feature-branch~1)] second commit
+        Author: A U Thor <author@example.com>
+        Date: Thu Apr 7 15:14:13 2005 -0700
+        2 files changed, 2 insertions(+)
+        create mode 100644 file1
+        create mode 100644 file2
+       Committed: 0001 second commit
+       Merging unrelated-onto-branch with HEAD~0
+       Merging:
+       $(git rev-parse --short rebased-feature-branch~1) second commit
+       $(git rev-parse --short feature-branch) third commit
+       found 1 common ancestor:
+       $(git rev-parse --short feature-branch~1) second commit
+       [detached HEAD $(git rev-parse --short rebased-feature-branch)] third commit
+        Author: A U Thor <author@example.com>
+        Date: Thu Apr 7 15:15:13 2005 -0700
+        1 file changed, 1 insertion(+)
+        create mode 100644 file3
+       Committed: 0002 third commit
+       All done.
+       Applying autostash resulted in conflicts.
+       Your changes are safe in the stash.
+       You can run "git stash pop" or "git stash drop" at any time.
+       EOF
+}
+
 testrebase () {
        type=$1
        dotest=$2
@@ -198,10 +259,9 @@ testrebase () {
                test_config rebase.autostash true &&
                git reset --hard &&
                git checkout -b rebased-feature-branch feature-branch &&
-               test_when_finished git branch -D rebased-feature-branch &&
                echo dirty >file4 &&
                git add file4 &&
-               git rebase$type unrelated-onto-branch &&
+               git rebase$type unrelated-onto-branch >actual 2>&1 &&
                test_path_is_missing $dotest &&
                git reset --hard &&
                grep unrelated file4 &&
@@ -210,6 +270,13 @@ testrebase () {
                git stash pop &&
                grep dirty file4
        '
+
+       test_expect_success "rebase$type: check output with conflicting stash" '
+               test_when_finished git branch -D rebased-feature-branch &&
+               suffix=${type#\ --} && suffix=${suffix:-am} &&
+               create_expected_failure_$suffix &&
+               test_cmp expected actual
+       '
 }
 
 test_expect_success "rebase: fast-forward rebase" '