[PATCH 0/3] Add regression tests for recent rebase -i fixes

Subsystems: the rest · Maintainer: Linus Torvalds

Series: 3 patches touching 9 files, +117/-2

STALE3417d SUPERSEDED

Status: Superseded by v3 (posted 2017-06-19). [go to v3]

Revision v1 (2 revisions archived).

Revisions (2)
  1. v1 current
  2. v3 [diff against previous]

18 messages, 2 authors, 2017-06-19 · open the first message on its own page

[PATCH 0/3] Add regression tests for recent rebase -i fixes

From: Phillip Wood <hidden>
Date: 2017-05-31 10:42:39

From: Phillip Wood <redacted>

These patches add some tests for the fixes I sent the week before
last. The output tests check the messages for stashes that apply and
fail for all three variants of rebase. They are quite strict but I
couldn't think of a better way to check that the output is correct and
doesn't contain anything it isn't meant to (such as the output of git
status).


Phillip Wood (3):
  rebase -i: Add test for reflog message
  rebase: Add tests for console output
  rebase: Add tests for console output with conflicting stash

 t/t3404-rebase-interactive.sh        |  7 +++++++
 t/t3420-rebase-autostash.sh          | 20 ++++++++++++++++++--
 t/t3420/expected-fail-am             |  8 ++++++++
 t/t3420/expected-fail-interactive    |  6 ++++++
 t/t3420/expected-fail-merge          | 32 ++++++++++++++++++++++++++++++++
 t/t3420/expected-success-am          |  6 ++++++
 t/t3420/expected-success-interactive |  4 ++++
 t/t3420/expected-success-merge       | 30 ++++++++++++++++++++++++++++++
 t/t3420/remove-ids.sed               |  6 ++++++
 9 files changed, 117 insertions(+), 2 deletions(-)
 create mode 100644 t/t3420/expected-fail-am
 create mode 100644 t/t3420/expected-fail-interactive
 create mode 100644 t/t3420/expected-fail-merge
 create mode 100644 t/t3420/expected-success-am
 create mode 100644 t/t3420/expected-success-interactive
 create mode 100644 t/t3420/expected-success-merge
 create mode 100644 t/t3420/remove-ids.sed

-- 
2.13.0

[PATCH 3/3] rebase: Add tests for console output with conflicting stash

From: Phillip Wood <hidden>
Date: 2017-05-31 10:42:41

From: Phillip Wood <redacted>

Check that the console output is what we expect when restoring
autostashed changes fails.

Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh       | 10 +++++++++-
 t/t3420/expected-fail-am          |  8 ++++++++
 t/t3420/expected-fail-interactive |  6 ++++++
 t/t3420/expected-fail-merge       | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 886be63c6d13e1ac4197a1b185659fb3d7d7eb26..4ff0d7aebd66b0ce091ceb11986b3928503c8c5f 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -148,7 +148,7 @@ testrebase() {
 		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 >tmp 2>&1 &&
 		test_path_is_missing $dotest &&
 		git reset --hard &&
 		grep unrelated file4 &&
@@ -157,6 +157,14 @@ testrebase() {
 		git stash pop &&
 		grep dirty file4
 	'
+
+	test_expect_success "rebase$type: check output with conflicting stash" '
+		suffix=${type#\ -} && suffix=${suffix:--am} &&
+		sed -f $TEST_DIRECTORY/t3420/remove-ids.sed tmp \
+			>actual-fail$suffix &&
+		test_cmp $TEST_DIRECTORY/t3420/expected-fail$suffix \
+			actual-fail$suffix
+	'
 }
 
 test_expect_success "rebase: fast-forward rebase" '
diff --git a/t/t3420/expected-fail-am b/t/t3420/expected-fail-am
new file mode 100644
index 0000000000000000000000000000000000000000..1d643fa2ef7e67f1ad1a49a02e81d2d6c66e6920
--- /dev/null
+++ b/t/t3420/expected-fail-am
@@ -0,0 +1,8 @@
+Created autostash: XXX
+HEAD is now at XXX 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.
diff --git a/t/t3420/expected-fail-interactive b/t/t3420/expected-fail-interactive
new file mode 100644
index 0000000000000000000000000000000000000000..9d1dd5264237e8f58e1960c6c0fb5b736df6f86d
--- /dev/null
+++ b/t/t3420/expected-fail-interactive
@@ -0,0 +1,6 @@
+Created autostash: XXX
+HEAD is now at XXX third commit
+Rebasing (1/2)\rRebasing (2/2)\rSuccessfully rebased and updated refs/heads/rebased-feature-branch.
+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.
diff --git a/t/t3420/expected-fail-merge b/t/t3420/expected-fail-merge
new file mode 100644
index 0000000000000000000000000000000000000000..5dcb2ff3acdb93f55131d67ae227d231e097a2a2
--- /dev/null
+++ b/t/t3420/expected-fail-merge
@@ -0,0 +1,32 @@
+Created autostash: XXX
+HEAD is now at XXX third commit
+First, rewinding head to replay your work on top of it...
+Merging unrelated-onto-branch with HEAD~1
+Merging:
+XXX unrelated commit
+XXX second commit
+found 1 common ancestor:
+XXX initial commit
+[detached HEAD XXX] 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:
+XXX second commit
+XXX third commit
+found 1 common ancestor:
+XXX second commit
+[detached HEAD XXX] 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.
-- 
2.13.0

[PATCH 1/3] rebase -i: Add test for reflog message

From: Phillip Wood <hidden>
Date: 2017-05-31 10:42:42

From: Phillip Wood <redacted>

Check that the reflog message written to the branch reflog when the
rebase is completed is correct. This checks for regressions for the
fix in commit
4ab867b8fc rebase -i: fix reflog message

Signed-off-by: Phillip Wood <redacted>
---
 t/t3404-rebase-interactive.sh | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 5bd0275930b715c25507fc9744c8946e7f73900b..37821d245433f757fa13f0a3e27da0312bebb7db 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -169,6 +169,13 @@ test_expect_success 'reflog for the branch shows state before rebase' '
 	test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
 '
 
+test_expect_success 'reflog for the branch shows correct finish message' '
+	printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
+		"$(git rev-parse branch2)" >expected &&
+	git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'exchange two commits' '
 	set_fake_editor &&
 	FAKE_LINES="2 1" git rebase -i HEAD~2 &&
-- 
2.13.0

[PATCH 2/3] rebase: Add tests for console output

From: Phillip Wood <hidden>
Date: 2017-05-31 10:42:44

From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly is what we expect. To avoid this test depending on commit and
stash hashes it uses sed to replace them with XXX. The sed script also
replaces carriage returns in the output with '\r' to avoid embedded
'^M's in the expected output files. Unfortunately this means we still
end up with an embedded '^M' in the sed script which may not be
preserved when sending this. The last line of the sed script should be
+s/^M/\\r/g

Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh          | 10 +++++++++-
 t/t3420/expected-success-am          |  6 ++++++
 t/t3420/expected-success-interactive |  4 ++++
 t/t3420/expected-success-merge       | 30 ++++++++++++++++++++++++++++++
 t/t3420/remove-ids.sed               |  6 ++++++
 5 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index ab8a63e8d6dc643b28eb0c74ba3f032b7532226f..886be63c6d13e1ac4197a1b185659fb3d7d7eb26 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -53,12 +53,20 @@ testrebase() {
 		git checkout -b rebased-feature-branch feature-branch &&
 		test_when_finished git branch -D rebased-feature-branch &&
 		echo dirty >>file3 &&
-		git rebase$type unrelated-onto-branch &&
+		git rebase$type unrelated-onto-branch >tmp 2>&1 &&
 		grep unrelated file4 &&
 		grep dirty file3 &&
 		git checkout feature-branch
 	'
 
+	test_expect_success "rebase$type --autostash: check output" '
+		suffix=${type#\ -} && suffix=${suffix:--am} &&
+		sed -f $TEST_DIRECTORY/t3420/remove-ids.sed tmp \
+			>actual-success$suffix &&
+		test_cmp $TEST_DIRECTORY/t3420/expected-success$suffix \
+			actual-success$suffix
+	'
+
 	test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
 		test_config rebase.autostash true &&
 		git reset --hard &&
diff --git a/t/t3420/expected-success-am b/t/t3420/expected-success-am
new file mode 100644
index 0000000000000000000000000000000000000000..c18ded04f703ed2aa83d5e62589a908d0a44cf7e
--- /dev/null
+++ b/t/t3420/expected-success-am
@@ -0,0 +1,6 @@
+Created autostash: XXX
+HEAD is now at XXX third commit
+First, rewinding head to replay your work on top of it...
+Applying: second commit
+Applying: third commit
+Applied autostash.
diff --git a/t/t3420/expected-success-interactive b/t/t3420/expected-success-interactive
new file mode 100644
index 0000000000000000000000000000000000000000..b31f71c95ddc9c18ce9956c1aadf53cedd966801
--- /dev/null
+++ b/t/t3420/expected-success-interactive
@@ -0,0 +1,4 @@
+Created autostash: XXX
+HEAD is now at XXX third commit
+Rebasing (1/2)\rRebasing (2/2)\rSuccessfully rebased and updated refs/heads/rebased-feature-branch.
+Applied autostash.
diff --git a/t/t3420/expected-success-merge b/t/t3420/expected-success-merge
new file mode 100644
index 0000000000000000000000000000000000000000..66386f7cb5242a255d9cc64aad741e651ec7ec1e
--- /dev/null
+++ b/t/t3420/expected-success-merge
@@ -0,0 +1,30 @@
+Created autostash: XXX
+HEAD is now at XXX third commit
+First, rewinding head to replay your work on top of it...
+Merging unrelated-onto-branch with HEAD~1
+Merging:
+XXX unrelated commit
+XXX second commit
+found 1 common ancestor:
+XXX initial commit
+[detached HEAD XXX] 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:
+XXX second commit
+XXX third commit
+found 1 common ancestor:
+XXX second commit
+[detached HEAD XXX] 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.
+Applied autostash.
diff --git a/t/t3420/remove-ids.sed b/t/t3420/remove-ids.sed
new file mode 100644
index 0000000000000000000000000000000000000000..9e9048b02bd04d287461543d85db0bb715b89f8c
--- /dev/null
+++ b/t/t3420/remove-ids.sed
@@ -0,0 +1,6 @@
+s/^\(Created autostash: \)[0-9a-f]\{6,\}$/\1XXX/
+s/^\(HEAD is now at \)[0-9a-f]\{6,\}\( .* commit\)$/\1XXX\2/
+s/^[0-9a-f]\{6,\}\( .* commit\)$/XXX\1/
+s/\(detached HEAD \)[0-9a-f]\{6,\}/\1XXX/
+s/\(could not apply \)[0-9a-f]\{6,\}/\1XXX/g
+s/
/\\r/g
-- 
2.13.0

Re: [PATCH 2/3] rebase: Add tests for console output

From: Phillip Wood <hidden>
Date: 2017-05-31 19:03:01

On 31/05/17 11:42, Phillip Wood wrote:
From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly is what we expect. To avoid this test depending on commit and
stash hashes it uses sed to replace them with XXX. The sed script also
replaces carriage returns in the output with '\r' to avoid embedded
'^M's in the expected output files. Unfortunately this means we still
end up with an embedded '^M' in the sed script which may not be
preserved when sending this. The last line of the sed script should be
+s/^M/\\r/g
Thinking about this it might be better to create the sed script with printf when running the test
quoted hunk
Signed-off-by: Phillip Wood <redacted>
---
  t/t3420-rebase-autostash.sh          | 10 +++++++++-
  t/t3420/expected-success-am          |  6 ++++++
  t/t3420/expected-success-interactive |  4 ++++
  t/t3420/expected-success-merge       | 30 ++++++++++++++++++++++++++++++
  t/t3420/remove-ids.sed               |  6 ++++++
  5 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index ab8a63e8d6dc643b28eb0c74ba3f032b7532226f..886be63c6d13e1ac4197a1b185659fb3d7d7eb26 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -53,12 +53,20 @@ testrebase() {
  		git checkout -b rebased-feature-branch feature-branch &&
  		test_when_finished git branch -D rebased-feature-branch &&
  		echo dirty >>file3 &&
-		git rebase$type unrelated-onto-branch &&
+		git rebase$type unrelated-onto-branch >tmp 2>&1 &&
  		grep unrelated file4 &&
  		grep dirty file3 &&
  		git checkout feature-branch
  	'
  
+	test_expect_success "rebase$type --autostash: check output" '
+		suffix=${type#\ -} && suffix=${suffix:--am} &&
+		sed -f $TEST_DIRECTORY/t3420/remove-ids.sed tmp \
+			>actual-success$suffix &&
+		test_cmp $TEST_DIRECTORY/t3420/expected-success$suffix \
+			actual-success$suffix
+	'
+
  	test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
  		test_config rebase.autostash true &&
  		git reset --hard &&
diff --git a/t/t3420/expected-success-am b/t/t3420/expected-success-am
new file mode 100644
index 0000000000000000000000000000000000000000..c18ded04f703ed2aa83d5e62589a908d0a44cf7e
--- /dev/null
+++ b/t/t3420/expected-success-am

66 more quoted lines

Re: [PATCH 2/3] rebase: Add tests for console output

From: Johannes Schindelin <hidden>
Date: 2017-06-01 12:56:22

Hi Phillip,

On Wed, 31 May 2017, Phillip Wood wrote:
From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly is what we expect. To avoid this test depending on commit and
stash hashes it uses sed to replace them with XXX. The sed script also
replaces carriage returns in the output with '\r' to avoid embedded
'^M's in the expected output files. Unfortunately this means we still
end up with an embedded '^M' in the sed script which may not be
preserved when sending this. The last line of the sed script should be
+s/^M/\\r/g
Like Junio pointed out, this sed script would not be portable. To
elaborate: there are two major variants of sed out there, GNU sed and BSD
sed. Typically GNU sed allows a little more powerful instructions, e.g. \t
and \r.

But we should simply take a step back and ask why test_cmp is not enough
to ignore the CRs in the output?

Also, about the commit IDs. As long as the tests are consistent (i.e. they
use test_commit rather than plain `git commit`, or at least call
`test_tick` beforehand), the commit IDs should actually be identical
between runs and not depend on the time of day or the date.

The only exception to that rule is when some previous test cases call
`test_commit` but are guarded behind some prereq and may not be executed
at all. In that case, the precise commit IDs depend on the particular set
of active prereqs.

But as far as I can tell, t3420 does not have any test cases guarded by
prereqs.

Taking an additional step back, I wonder whether we have to hard-code the
commit IDs (or XXX) to begin with. Why not generate the `expect` files
with the information at hand? We can simply ask `git rev-parse --short`.

For the stash's commit ID, there is no record in the ref space, of course
(because it was created with `git stash create`). But I think in this
case, it is legitimate to simply grep the output.

That way, the test would be precise and resilient.

So for example instead of adding the t/t3420/expected-success-am verbatim,
you could generate the output via

	cat >expect <<-EOF
	$(grep "^Created autostash: [0-9a-f][0-9a-f]*\\$" output)
	HEAD is now at $(git rev-parse --short HEAD~2) third commit
	First, rewinding head to replay your work on top of it...
	Applying: second commit

6 more lines

Re: [PATCH 2/3] rebase: Add tests for console output

From: Phillip Wood <hidden>
Date: 2017-06-07 10:47:11

Hi Johannes

Thanks for your feedback
On 01/06/17 13:56, Johannes Schindelin wrote:
Hi Phillip,

On Wed, 31 May 2017, Phillip Wood wrote:
quoted
From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly is what we expect. To avoid this test depending on commit and
stash hashes it uses sed to replace them with XXX. The sed script also
replaces carriage returns in the output with '\r' to avoid embedded
'^M's in the expected output files. Unfortunately this means we still
end up with an embedded '^M' in the sed script which may not be
preserved when sending this. The last line of the sed script should be
+s/^M/\\r/g
Like Junio pointed out, this sed script would not be portable. To
elaborate: there are two major variants of sed out there, GNU sed and BSD
sed. Typically GNU sed allows a little more powerful instructions, e.g. \t
and \r.
I'm confused by this as my script does not use the escape sequence "\r"
out of portability concerns. It has a literal carriage return as you get
from typing Ctrl-Q Ctrl-M in emacs or Ctrl-V Ctrl-M in bash which I
think should be portable and replaces the carriage returns in git's
output with the literal string '\r'. I did this so that the expected
files don't have control characters in them that mess up the display
when you cat them or read them in an email client
But we should simply take a step back and ask why test_cmp is not enough
to ignore the CRs in the output?

Also, about the commit IDs. As long as the tests are consistent (i.e. they
use test_commit rather than plain `git commit`, or at least call
`test_tick` beforehand), the commit IDs should actually be identical
between runs and not depend on the time of day or the date.

The only exception to that rule is when some previous test cases call
`test_commit` but are guarded behind some prereq and may not be executed
at all. In that case, the precise commit IDs depend on the particular set
of active prereqs.
The other exceptions are when the commit hash algorithm changes or the
contents of the commits changes because of some update to the test
script. That's why I didn't want to rely on matching fixed SHA1s
But as far as I can tell, t3420 does not have any test cases guarded by
prereqs.

Taking an additional step back, I wonder whether we have to hard-code the
commit IDs (or XXX) to begin with. Why not generate the `expect` files
with the information at hand? We can simply ask `git rev-parse --short`.

For the stash's commit ID, there is no record in the ref space, of course
(because it was created with `git stash create`). But I think in this
case, it is legitimate to simply grep the output.
That's a good approach to handling the stash hash if we want to generate
the expected files from the test script
That way, the test would be precise and resilient.

So for example instead of adding the t/t3420/expected-success-am verbatim,
you could generate the output via

	cat >expect <<-EOF
	$(grep "^Created autostash: [0-9a-f][0-9a-f]*\\$" output)
	HEAD is now at $(git rev-parse --short HEAD~2) third commit
	First, rewinding head to replay your work on top of it...
	Applying: second commit
	Applying: third commit
	Applied autostash.
	EOF
This approach works well for the cases where there aren't control
characters embedded in git's output, but for the interactive tests there
are so we'd end up with control characters in the test script which I
wanted to avoid or doing $(printf '\r'). I steered clear of generating
the expected file in the test as i) it was more work (both for me
(rebase --merge has a few commit hashes in it's output) and when the
script is running) and ii) it's a bit messy to implement given the way
the tests are structured in a helper function that's called with a
parameter indicating the type of rebase to test.

I can go ahead with generating the expected files from the script if you
really want but I wonder if changing the test to generate the sed script
with printf as below might be a simpler way to mitigate the carriage
return problem, though it would be less strict than generating the real
hashes with rev-parse.
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -189,6 +189,16 @@ test_expect_success "rebase: noop rebase" '
 	git checkout feature-branch
 '

+test_expect_sucess 'rebase: create sed script to sanitize output' '
+	printf "\
+s/^\(Created autostash: \)[0-9a-f]\{6,\}$/\1XXX/
+s/^\(HEAD is now at \)[0-9a-f]\{6,\}\( .* commit\)$/\1XXX\2/
+s/^[0-9a-f]\{6,\}\( .* commit\)$/XXX\1/
+s/\(detached HEAD \)[0-9a-f]\{6,\}/\1XXX/
+s/\(could not apply \)[0-9a-f]\{6,\}/\1XXX/g
+s/\\r/\\r/g" >$TEST_DIRECTORY/t4320/remove-ids.sed
+'
+
Let me know what you think,

Best Wishes

Phillip

[PATCH v2 0/3] Add regression tests for rectent rebase -i fixes

From: Phillip Wood <hidden>
Date: 2017-06-14 10:24:59

From: Phillip Wood <redacted>

I've revised the second two tests as Johannes suggested to drop the
sed script. The first one is unchanged.

Phillip Wood (3):
  rebase -i: Add test for reflog message
  rebase: Add regression tests for console output
  rebase: Add more regression tests for console output

 t/t3404-rebase-interactive.sh |   7 +++
 t/t3420-rebase-autostash.sh   | 138 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 141 insertions(+), 4 deletions(-)

-- 
2.13.0

[PATCH v2 1/3] rebase -i: Add test for reflog message

From: Phillip Wood <hidden>
Date: 2017-06-14 10:25:02

From: Phillip Wood <redacted>

Check that the reflog message written to the branch reflog when the
rebase is completed is correct

Signed-off-by: Phillip Wood <redacted>
---
 t/t3404-rebase-interactive.sh | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 5bd0275930b715c25507fc9744c8946e7f73900b..37821d245433f757fa13f0a3e27da0312bebb7db 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -169,6 +169,13 @@ test_expect_success 'reflog for the branch shows state before rebase' '
 	test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
 '
 
+test_expect_success 'reflog for the branch shows correct finish message' '
+	printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
+		"$(git rev-parse branch2)" >expected &&
+	git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'exchange two commits' '
 	set_fake_editor &&
 	FAKE_LINES="2 1" git rebase -i HEAD~2 &&
-- 
2.13.0

[PATCH v2 2/3] rebase: Add regression tests for console output

From: Phillip Wood <hidden>
Date: 2017-06-14 10:25:07

From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly 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 [off-list ref]
Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh | 66 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 64 insertions(+), 2 deletions(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index ab8a63e8d6dc643b28eb0c74ba3f032b7532226f..2cbc2e89cd026c370a86da35e181d77f27081c7a 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -33,6 +33,62 @@ test_expect_success setup '
 	git commit -m "related commit"
 '
 
+create_expected_success_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
+	Applied autostash.
+	EOF
+}
+
+create_expected_success_interactive() {
+	cr=$'\r' &&
+	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
+	Rebasing (1/2)${cr}Rebasing (2/2)${cr}Successfully rebased and updated refs/heads/rebased-feature-branch.
+	Applied autostash.
+	EOF
+}
+
+create_expected_success_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.
+	Applied autostash.
+	EOF
+}
+
 testrebase() {
 	type=$1
 	dotest=$2
@@ -51,14 +107,20 @@ 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 >>file3 &&
-		git rebase$type unrelated-onto-branch &&
+		git rebase$type unrelated-onto-branch >actual 2>&1 &&
 		grep unrelated file4 &&
 		grep dirty file3 &&
 		git checkout feature-branch
 	'
 
+	test_expect_success "rebase$type --autostash: check output" '
+		test_when_finished git branch -D rebased-feature-branch &&
+		suffix=${type#\ --} && suffix=${suffix:-am} &&
+		create_expected_success_$suffix &&
+		test_cmp expected actual
+	'
+
 	test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
 		test_config rebase.autostash true &&
 		git reset --hard &&
-- 
2.13.0

[PATCH v2 3/3] rebase: Add more regression tests for console output

From: Phillip Wood <hidden>
Date: 2017-06-14 10:25:11

From: Phillip Wood <redacted>

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 [off-list ref]
Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh | 72 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 70 insertions(+), 2 deletions(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 2cbc2e89cd026c370a86da35e181d77f27081c7a..325ec75353b200bb88ab223e4a3b87d885cf2cf2 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -89,6 +89,68 @@ 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() {
+	cr=$'\r' &&
+	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
+	Rebasing (1/2)${cr}Rebasing (2/2)${cr}Successfully rebased and updated refs/heads/rebased-feature-branch.
+	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_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
@@ -199,10 +261,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 &&
@@ -211,6 +272,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" '
-- 
2.13.0

Re: [PATCH 2/3] rebase: Add tests for console output

From: Johannes Schindelin <hidden>
Date: 2017-06-14 12:52:12

Hi Phillip,

On Wed, 7 Jun 2017, Phillip Wood wrote:
On 01/06/17 13:56, Johannes Schindelin wrote:
quoted
On Wed, 31 May 2017, Phillip Wood wrote:
quoted
From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly is what we expect. To avoid this test depending on commit and
stash hashes it uses sed to replace them with XXX. The sed script also
replaces carriage returns in the output with '\r' to avoid embedded
'^M's in the expected output files. Unfortunately this means we still
end up with an embedded '^M' in the sed script which may not be
preserved when sending this. The last line of the sed script should be
+s/^M/\\r/g
Like Junio pointed out, this sed script would not be portable. To
elaborate: there are two major variants of sed out there, GNU sed and BSD
sed. Typically GNU sed allows a little more powerful instructions, e.g. \t
and \r.
I'm confused by this as my script does not use the escape sequence "\r"
out of portability concerns. It has a literal carriage return as you get
from typing Ctrl-Q Ctrl-M in emacs or Ctrl-V Ctrl-M in bash which I
think should be portable and replaces the carriage returns in git's
output with the literal string '\r'. I did this so that the expected
files don't have control characters in them that mess up the display
when you cat them or read them in an email client
Junio elaborated elsewhere what my main concern is: while a literal
backslash followed by a lower-case r may be unportable, a plain CR byte is
almost certainly unportable.
quoted
Taking an additional step back, I wonder whether we have to hard-code
the commit IDs (or XXX) to begin with. Why not generate the `expect`
files with the information at hand? We can simply ask `git rev-parse
--short`.

For the stash's commit ID, there is no record in the ref space, of
course (because it was created with `git stash create`). But I think
in this case, it is legitimate to simply grep the output.
That's a good approach to handling the stash hash if we want to generate
the expected files from the test script
I would strongly favor that, especially since it would make the transition
away from SHA-1 easier rather than more difficult.
quoted hunk
quoted
That way, the test would be precise and resilient.

So for example instead of adding the t/t3420/expected-success-am verbatim,
you could generate the output via

	cat >expect <<-EOF
	$(grep "^Created autostash: [0-9a-f][0-9a-f]*\\$" output)
	HEAD is now at $(git rev-parse --short HEAD~2) third commit
	First, rewinding head to replay your work on top of it...
	Applying: second commit
	Applying: third commit
	Applied autostash.
	EOF
This approach works well for the cases where there aren't control
characters embedded in git's output, but for the interactive tests there
are so we'd end up with control characters in the test script which I
wanted to avoid or doing $(printf '\r'). I steered clear of generating
the expected file in the test as i) it was more work (both for me
(rebase --merge has a few commit hashes in it's output) and when the
script is running) and ii) it's a bit messy to implement given the way
the tests are structured in a helper function that's called with a
parameter indicating the type of rebase to test.

I can go ahead with generating the expected files from the script if you
really want but I wonder if changing the test to generate the sed script
with printf as below might be a simpler way to mitigate the carriage
return problem, though it would be less strict than generating the real
hashes with rev-parse.
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -189,6 +189,16 @@ test_expect_success "rebase: noop rebase" '
 	git checkout feature-branch
 '

+test_expect_sucess 'rebase: create sed script to sanitize output' '
+	printf "\
+s/^\(Created autostash: \)[0-9a-f]\{6,\}$/\1XXX/
+s/^\(HEAD is now at \)[0-9a-f]\{6,\}\( .* commit\)$/\1XXX\2/

8 more quoted lines

I'd rather generate the expected output. If there are control characters
to be embedded anywhere, we have good prior art to do that: see the
q_to_nul(), q_to_cr() and q_to_tab() functions in test-lib-functions.

If you still think that it is too daunting, please point me to a branch
(you're on GitHub, right?) and I can try my hand at a PR.

Ciao,
Dscho

Re: [PATCH v2 0/3] Add regression tests for rectent rebase -i fixes

From: Johannes Schindelin <hidden>
Date: 2017-06-14 20:36:08

Hi Phillip,

On Wed, 14 Jun 2017, Phillip Wood wrote:
From: Phillip Wood <redacted>

I've revised the second two tests as Johannes suggested to drop the
sed script. The first one is unchanged.
This iteration looks pretty good to me!

Ciao,
Johannes

[PATCH v3 0/4] Add regression tests for recent rebase -i fixes

From: Phillip Wood <hidden>
Date: 2017-06-19 17:56:20

From: Phillip Wood <redacted>

I've updated the second two tests to be portable using q_to_cr() as
Johannes suggested and added his patch to fix the autostash messages
going to stdout rather than stderr. The reflog message test is
unchanged. Thanks to Johannes for his help and to Junio for picking up
the bashism in the last iteration.

Johannes Schindelin (1):
  sequencer: print autostash messages to stderr

Phillip Wood (3):
  rebase -i: Add test for reflog message
  rebase: Add regression tests for console output
  rebase: Add more regression tests for console output

 git-rebase.sh                 |   4 +-
 sequencer.c                   |  11 ++--
 t/t3404-rebase-interactive.sh |   7 +++
 t/t3420-rebase-autostash.sh   | 136 ++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 147 insertions(+), 11 deletions(-)

-- 
2.13.0

[PATCH v3 1/4] sequencer: print autostash messages to stderr

From: Phillip Wood <hidden>
Date: 2017-06-19 17:57:04

From: Johannes Schindelin <redacted>

The rebase messages are printed to stderr traditionally. However due
to a bug introduced in 587947750bd (rebase: implement --[no-]autostash
and rebase.autostash, 2013-05-12) which was faithfully copied when
reimplementing parts of the interactive rebase in the sequencer the
autostash messages are printed to stdout instead.

It is time to fix that: let's print the autostash messages to stderr
instead of stdout.

Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Phillip Wood <redacted>
---
 git-rebase.sh |  4 ++--
 sequencer.c   | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index db1deed8464f0643763ed6e3c5e54221cad8c985..2cf73b88e8e83ca34b9eb319dbc2b0a220139b0f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -166,14 +166,14 @@ apply_autostash () {
 		stash_sha1=$(cat "$state_dir/autostash")
 		if git stash apply $stash_sha1 2>&1 >/dev/null
 		then
-			echo "$(gettext 'Applied autostash.')"
+			echo "$(gettext 'Applied autostash.')" >&2
 		else
 			git stash store -m "autostash" -q $stash_sha1 ||
 			die "$(eval_gettext "Cannot store \$stash_sha1")"
 			gettext '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.
-'
+' >&2
 		fi
 	fi
 }
diff --git a/sequencer.c b/sequencer.c
index a23b948ac148304dbebfe38955ec8b40cab3e1e5..606750b1e0c900a9fb43cea224d27ab36ca29ab9 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1921,7 +1921,7 @@ static int apply_autostash(struct replay_opts *opts)
 	argv_array_push(&child.args, "apply");
 	argv_array_push(&child.args, stash_sha1.buf);
 	if (!run_command(&child))
-		printf(_("Applied autostash.\n"));
+		fprintf(stderr, _("Applied autostash.\n"));
 	else {
 		struct child_process store = CHILD_PROCESS_INIT;
 
@@ -1935,10 +1935,11 @@ static int apply_autostash(struct replay_opts *opts)
 		if (run_command(&store))
 			ret = error(_("cannot store %s"), stash_sha1.buf);
 		else
-			printf(_("Applying autostash resulted in conflicts.\n"
-				"Your changes are safe in the stash.\n"
-				"You can run \"git stash pop\" or"
-				" \"git stash drop\" at any time.\n"));
+			fprintf(stderr,
+				_("Applying autostash resulted in conflicts.\n"
+				  "Your changes are safe in the stash.\n"
+				  "You can run \"git stash pop\" or"
+				  " \"git stash drop\" at any time.\n"));
 	}
 
 	strbuf_release(&stash_sha1);
-- 
2.13.0

[PATCH v3 2/4] rebase -i: Add test for reflog message

From: Phillip Wood <hidden>
Date: 2017-06-19 17:57:33

From: Phillip Wood <redacted>

Check that the reflog message written to the branch reflog when the
rebase is completed is correct

Signed-off-by: Phillip Wood <redacted>
---
 t/t3404-rebase-interactive.sh | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 5bd0275930b715c25507fc9744c8946e7f73900b..37821d245433f757fa13f0a3e27da0312bebb7db 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -169,6 +169,13 @@ test_expect_success 'reflog for the branch shows state before rebase' '
 	test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
 '
 
+test_expect_success 'reflog for the branch shows correct finish message' '
+	printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
+		"$(git rev-parse branch2)" >expected &&
+	git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'exchange two commits' '
 	set_fake_editor &&
 	FAKE_LINES="2 1" git rebase -i HEAD~2 &&
-- 
2.13.0

[PATCH v3 3/4] rebase: Add regression tests for console output

From: Phillip Wood <hidden>
Date: 2017-06-19 17:57:38

From: Phillip Wood <redacted>

Check the console output when using --autostash and the stash applies
cleanly 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 [off-list ref]
Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh | 65 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index ab8a63e8d6dc643b28eb0c74ba3f032b7532226f..cd1012798cb300f4f1ddeba6fdcad544ca9ea1d9 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -33,6 +33,61 @@ test_expect_success setup '
 	git commit -m "related commit"
 '
 
+create_expected_success_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
+	Applied autostash.
+	EOF
+}
+
+create_expected_success_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)QApplied autostash.
+	Successfully rebased and updated refs/heads/rebased-feature-branch.
+	EOF
+}
+
+create_expected_success_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.
+	Applied autostash.
+	EOF
+}
+
 testrebase() {
 	type=$1
 	dotest=$2
@@ -51,14 +106,20 @@ 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 >>file3 &&
-		git rebase$type unrelated-onto-branch &&
+		git rebase$type unrelated-onto-branch >actual 2>&1 &&
 		grep unrelated file4 &&
 		grep dirty file3 &&
 		git checkout feature-branch
 	'
 
+	test_expect_success "rebase$type --autostash: check output" '
+		test_when_finished git branch -D rebased-feature-branch &&
+		suffix=${type#\ --} && suffix=${suffix:-am} &&
+		create_expected_success_$suffix &&
+		test_cmp expected actual
+	'
+
 	test_expect_success "rebase$type: dirty index, non-conflicting rebase" '
 		test_config rebase.autostash true &&
 		git reset --hard &&
-- 
2.13.0

[PATCH v3 4/4] rebase: Add more regression tests for console output

From: Phillip Wood <hidden>
Date: 2017-06-19 17:57:42

From: Phillip Wood <redacted>

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 [off-list ref]
Signed-off-by: Phillip Wood <redacted>
---
 t/t3420-rebase-autostash.sh | 71 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 69 insertions(+), 2 deletions(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index cd1012798cb300f4f1ddeba6fdcad544ca9ea1d9..2c01ae6ad2a104940e388013984e7fa2a0d5aed5 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -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" '
-- 
2.13.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help