git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git add -p “Your edited hunk does not apply. Edit again”
@ 2015-04-14  1:56 Tanky Woo
  2015-04-14  9:43 ` Matthieu Moy
  0 siblings, 1 reply; 17+ messages in thread
From: Tanky Woo @ 2015-04-14  1:56 UTC (permalink / raw)
  To: git

I asked this question in stackoverflow a few days ago, but get no answer.

link: http://stackoverflow.com/questions/29518944/git-add-p-your-edited-hunk-does-not-apply-
edit-again

---

An example, the original file:

test:
       make clean
       nosetests

clean:
       rm -rf htmlcov
       rm -rf build dist
       coverage erase
The file after changed:

HTMLCOV="htmlcov/"

test:
       make clean
       nosetests

clean:
       coverage erase
       rm -rf htmlcov
       rm -rf build dist

covhtml:
       make clean
       nosetests
       coverage html
       cd ${HTMLCOV} && python -m SimpleHTTPServer
This is the diff:

diff --git a/mf b/mf
index b9ca06e..6316e17 100644
--- a/mf
+++ b/mf
@@ -1,8 +1,16 @@
+HTMLCOV="htmlcov/"            # Hunk 1
+
 test:
        make clean
        nosetests

 clean:
+       coverage erase         # Hunk 2
        rm -rf htmlcov
        rm -rf build dist
-       coverage erase         # Hunk 3
+
+covhtml:
+       make clean
+       nosetests
+       coverage html
+       cd ${HTMLCOV} && python -m SimpleHTTPServer
I use git add -p, want only to add:

+       coverage erase
        rm -rf htmlcov
        rm -rf build dist
-       coverage erase
So I first use s to split hunks, and n to ignore first add,
then use y to add second hunk, the third hunk 
is:

-       coverage erase
+
+covhtml:
+       make clean
+       nosetests
+       coverage html
+       cd ${HTMLCOV} && python -m SimpleHTTPServer
So I use e to manually edit the hunk, I delete all the + lines, it seems:

# Manual hunk edit mode -- see bottom for a quick guide
@@ -6,3 +9,8 @@
        rm -rf htmlcov
        rm -rf build dist
-       coverage erase
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# ....
But when I saved, it says:

@@ -6,3 +9,8 @@
        rm -rf htmlcov
        rm -rf build dist
-       coverage erase
+
+covhtml:
+       make clean
+       nosetests
+       coverage html
+       cd ${HTMLCOV} && python -m SimpleHTTPServer
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? e
error: patch failed: mf:1
error: mf: patch does not apply
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?
And then I change to @@ from-file-range to-file-range @@ part to:

@@ -6,3 +9,2 @@
There is still the same problem.

If I first add only the second Hunk, 
and then I run git add -p xxx again, and edit the hunk, 
there is no problem. Why?

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Git add -p “Your edited hunk does not apply. Edit again”
  2015-04-14  1:56 Git add -p “Your edited hunk does not apply. Edit again” Tanky Woo
@ 2015-04-14  9:43 ` Matthieu Moy
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
       [not found]   ` <CALv9gbMshdNhB58Otx5h8rmtCAU4qo9eNTqKSMzD_Phy7Sataw@mail.gmail.com>
  0 siblings, 2 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14  9:43 UTC (permalink / raw)
  To: Tanky Woo; +Cc: git

Tanky Woo <wtq1990@gmail.com> writes:

> -       coverage erase
> +
> +covhtml:
> +       make clean
> +       nosetests
> +       coverage html
> +       cd ${HTMLCOV} && python -m SimpleHTTPServer
> So I use e to manually edit the hunk, I delete all the + lines, it seems:

I can reproduce on git.git's master. Actually, you don't even have to
edit the patch, just save and exit, and you get the same error message.
So it's clearly a bug.

I can get the same kind of bug with "stash -p", without even using the
'e' command, by doing "split" and then answer n, y. On a simpler example
with two hunks:

$ git stash -p
diff --git a/bar.txt b/bar.txt
index 35fbd83..1d3fda3 100644
--- a/bar.txt
+++ b/bar.txt
@@ -1,4 +1,6 @@
 aaa
+added line 1
 bbb
+added line 2
 ccc
 ddd
Stash this hunk [y,n,q,a,d,/,s,e,?]? s
Split into 2 hunks.
@@ -1,2 +1,3 @@
 aaa
+added line 1
 bbb
Stash this hunk [y,n,q,a,d,/,j,J,g,e,?]? n
@@ -2,3 +3,4 @@
 bbb
+added line 2
 ccc
 ddd
Stash this hunk [y,n,q,a,d,/,K,g,e,?]? y

Saved working directory and index state WIP on master: 1cad001 abcd
error: patch failed: bar.txt:1
error: bar.txt: patch does not apply
Cannot remove worktree changes

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 0/4] demonstrate add -p and stash -p failures.
  2015-04-14  9:43 ` Matthieu Moy
@ 2015-04-14 11:32   ` Matthieu Moy
  2015-04-14 11:32     ` [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
                       ` (5 more replies)
       [not found]   ` <CALv9gbMshdNhB58Otx5h8rmtCAU4qo9eNTqKSMzD_Phy7Sataw@mail.gmail.com>
  1 sibling, 6 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 11:32 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthieu Moy

Playing a bit with add -p and stash -p, I can confirm the bug reported
by Tanky. This series just adds failing tests, but I couldn't debug it.

I've exhausted my Git time budget for now, so if someone wants to take
over and fix the bugs, feel free to do it!

Matthieu Moy (4):
  add -p: demonstrate failure when running 'edit' after a split
  t3904-stash-patch: fix test description
  t3904-stash-patch: factor PERL prereq at the top of the file
  stash -p: demonstrate failure of split with mixed y/n

 t/t3701-add-interactive.sh | 25 +++++++++++++++++++++++++
 t/t3904-stash-patch.sh     | 46 +++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 64 insertions(+), 7 deletions(-)

-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
@ 2015-04-14 11:32     ` Matthieu Moy
  2015-04-14 20:46       ` Eric Sunshine
  2015-04-14 11:32     ` [PATCH 2/4] t3904-stash-patch: fix test description Matthieu Moy
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 11:32 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthieu Moy

The test passes if one replaces the 'e' command with a 'y' command in
the 'add -p' session.

Reported-by: Tanky Woo <wtq1990@gmail.com>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3701-add-interactive.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 24ddd8a..b48a75c 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -335,6 +335,31 @@ test_expect_success 'split hunk "add -p (edit)"' '
 	! grep "^+15" actual
 '
 
+test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
+	cat >test <<-\EOF &&
+	5
+	10
+	20
+	21
+	30
+	31
+	40
+	50
+	60
+	EOF
+	git reset &&
+	# test sequence is s(plit), n(o), y(es), e(dit)
+	# q n q q is there to make sure we exit at the end.
+	for a in s n y e   q n q q
+	do
+		echo $a
+	done |
+	EDITOR=: git add -p 2>error &&
+	test_must_be_empty error &&
+	git diff >actual &&
+	! grep "^+31" actual
+'
+
 test_expect_success 'patch mode ignores unmerged entries' '
 	git reset --hard &&
 	test_commit conflict &&
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] t3904-stash-patch: fix test description
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
  2015-04-14 11:32     ` [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
@ 2015-04-14 11:32     ` Matthieu Moy
  2015-04-14 11:32     ` [PATCH 3/4] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 11:32 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthieu Moy

The old description is rather clearly a wrong cut-and-paste from
t2016-checkout-patch.sh.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 70655c1..9a59683 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-test_description='git checkout --patch'
+test_description='stash -p'
 . ./lib-patch-mode.sh
 
 test_expect_success PERL 'setup' '
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] t3904-stash-patch: factor PERL prereq at the top of the file
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
  2015-04-14 11:32     ` [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
  2015-04-14 11:32     ` [PATCH 2/4] t3904-stash-patch: fix test description Matthieu Moy
@ 2015-04-14 11:32     ` Matthieu Moy
  2015-04-14 11:32     ` [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 11:32 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 9a59683..0f8f47f 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -3,7 +3,13 @@
 test_description='stash -p'
 . ./lib-patch-mode.sh
 
-test_expect_success PERL 'setup' '
+if ! test_have_prereq PERL
+then
+	skip_all='skipping stash -p tests, perl not available'
+	test_done
+fi
+
+test_expect_success 'setup' '
 	mkdir dir &&
 	echo parent > dir/foo &&
 	echo dummy > bar &&
@@ -20,7 +26,7 @@ test_expect_success PERL 'setup' '
 
 # note: order of files with unstaged changes: HEAD bar dir/foo
 
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state dir/foo work index &&
 	(echo n; echo n; echo n) | test_must_fail git stash save -p &&
@@ -29,7 +35,7 @@ test_expect_success PERL 'saying "n" does nothing' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'git stash -p' '
+test_expect_success 'git stash -p' '
 	(echo y; echo n; echo y) | git stash save -p &&
 	verify_state HEAD committed HEADfile_index &&
 	verify_saved_state bar &&
@@ -41,7 +47,7 @@ test_expect_success PERL 'git stash -p' '
 	verify_state dir/foo work head
 '
 
-test_expect_success PERL 'git stash -p --no-keep-index' '
+test_expect_success 'git stash -p --no-keep-index' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state bar bar_work bar_index &&
 	set_state dir/foo work index &&
@@ -56,7 +62,7 @@ test_expect_success PERL 'git stash -p --no-keep-index' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'git stash --no-keep-index -p' '
+test_expect_success 'git stash --no-keep-index -p' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state bar bar_work bar_index &&
 	set_state dir/foo work index &&
@@ -71,7 +77,7 @@ test_expect_success PERL 'git stash --no-keep-index -p' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
 	verify_saved_head
 '
 
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
                       ` (2 preceding siblings ...)
  2015-04-14 11:32     ` [PATCH 3/4] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
@ 2015-04-14 11:32     ` Matthieu Moy
  2015-04-14 20:46       ` Eric Sunshine
  2015-04-14 18:00     ` [PATCH 0/4] demonstrate add -p and stash -p failures Junio C Hamano
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
  5 siblings, 1 reply; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 11:32 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 0f8f47f..6f053ff 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -81,4 +81,30 @@ test_expect_success 'none of this moved HEAD' '
 	verify_saved_head
 '
 
+test_expect_failure 'stash -p with split hunk' '
+	git reset --hard &&
+	cat >test <<-\EOF &&
+	aaa
+	bbb
+	ccc
+	EOF
+	git add test &&
+	git commit -m "initial" &&
+	cat >test <<-\EOF &&
+	aaa
+	added line 1
+	bbb
+	added line 2
+	ccc
+	EOF
+	for a in s n y q
+	do
+		echo $a
+	done |
+	test_might_fail git stash -p 2>error &&
+	! test_must_be_empty error &&
+	grep "added line 1" test &&
+	! grep "added line 2" test
+'
+
 test_done
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: Git add -p “Your edited hunk does not apply. Edit again”
       [not found]   ` <CALv9gbMshdNhB58Otx5h8rmtCAU4qo9eNTqKSMzD_Phy7Sataw@mail.gmail.com>
@ 2015-04-14 14:00     ` Matthieu Moy
  0 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-14 14:00 UTC (permalink / raw)
  To: Tanky Woo; +Cc: git

Tanky Woo <wtq1990@gmail.com> writes:

> Stash this hunk [y,n,q,a,d,/,j,J,g,e,?]? y
> @@ -2,3 +3,4 @@
>  bbb
> +added line 2
>  ccc
>  ddd
> Stash this hunk [y,n,q,a,d,/,K,g,e,?]? y

My version does n, y, not y, y. The problem is the mix of stashed/not
stashed hunks. See my other message for a reproducible test, it does
fail on Git master.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/4] demonstrate add -p and stash -p failures.
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
                       ` (3 preceding siblings ...)
  2015-04-14 11:32     ` [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
@ 2015-04-14 18:00     ` Junio C Hamano
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
  5 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2015-04-14 18:00 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git, Thomas Rast

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> Playing a bit with add -p and stash -p, I can confirm the bug reported
> by Tanky. This series just adds failing tests, but I couldn't debug it.
>
> I've exhausted my Git time budget for now, so if someone wants to take
> over and fix the bugs, feel free to do it!

I do not have time to dig this either for now, but I suspect this
"split a hunk into two overlapping hunks" issue may be related to
the caveat in the very original:


http://thread.gmane.org/gmane.comp.version-control.git/76650/focus=87197


where I seem to have said that the proposed change would make "add
-p" less robust than the original code (even without 'e'dit):

    Junio C Hamano wrote:
    > 
    > I recall that the original "add--interactive" carefully counted
    > numbers in hunks it reassembles (as it can let you split and then
    > you can choose to use both parts, which requires it to merge
    > overlapping hunks back), but if you are going to use --recount
    > anyway, perhaps we can discard that logic?  It may make the patch
    > application less robust, though.  I dunno.


It seems that we accepted that series saying "let's see what
happens" at the end, and I suspect we are seeing its consequences
;-).

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split
  2015-04-14 11:32     ` [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
@ 2015-04-14 20:46       ` Eric Sunshine
  0 siblings, 0 replies; 17+ messages in thread
From: Eric Sunshine @ 2015-04-14 20:46 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Junio C Hamano, Git List

On Tue, Apr 14, 2015 at 7:32 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> The test passes if one replaces the 'e' command with a 'y' command in
> the 'add -p' session.
>
> Reported-by: Tanky Woo <wtq1990@gmail.com>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index 24ddd8a..b48a75c 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -335,6 +335,31 @@ test_expect_success 'split hunk "add -p (edit)"' '
>         ! grep "^+15" actual
>  '
>
> +test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
> +       cat >test <<-\EOF &&
> +       5
> +       10
> +       20
> +       21
> +       30
> +       31
> +       40
> +       50
> +       60
> +       EOF
> +       git reset &&
> +       # test sequence is s(plit), n(o), y(es), e(dit)
> +       # q n q q is there to make sure we exit at the end.
> +       for a in s n y e   q n q q
> +       do
> +               echo $a
> +       done |

Simplified:

    printf '%s\n' s n y e q n q q |

> +       EDITOR=: git add -p 2>error &&
> +       test_must_be_empty error &&
> +       git diff >actual &&
> +       ! grep "^+31" actual
> +'
> +
>  test_expect_success 'patch mode ignores unmerged entries' '
>         git reset --hard &&
>         test_commit conflict &&
> --
> 2.4.0.rc1.42.g9642cc6

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n
  2015-04-14 11:32     ` [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
@ 2015-04-14 20:46       ` Eric Sunshine
  0 siblings, 0 replies; 17+ messages in thread
From: Eric Sunshine @ 2015-04-14 20:46 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Junio C Hamano, Git List

On Tue, Apr 14, 2015 at 7:32 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
> index 0f8f47f..6f053ff 100755
> --- a/t/t3904-stash-patch.sh
> +++ b/t/t3904-stash-patch.sh
> @@ -81,4 +81,30 @@ test_expect_success 'none of this moved HEAD' '
>         verify_saved_head
>  '
>
> +test_expect_failure 'stash -p with split hunk' '
> +       git reset --hard &&
> +       cat >test <<-\EOF &&
> +       aaa
> +       bbb
> +       ccc
> +       EOF
> +       git add test &&
> +       git commit -m "initial" &&
> +       cat >test <<-\EOF &&
> +       aaa
> +       added line 1
> +       bbb
> +       added line 2
> +       ccc
> +       EOF
> +       for a in s n y q
> +       do
> +               echo $a
> +       done |

Simplified:

    printf '%s\n' s n y q |

> +       test_might_fail git stash -p 2>error &&
> +       ! test_must_be_empty error &&
> +       grep "added line 1" test &&
> +       ! grep "added line 2" test
> +'
> +
>  test_done
> --
> 2.4.0.rc1.42.g9642cc6

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 0/5] demonstrate add -p and stash -p failures
  2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
                       ` (4 preceding siblings ...)
  2015-04-14 18:00     ` [PATCH 0/4] demonstrate add -p and stash -p failures Junio C Hamano
@ 2015-04-16  7:02     ` Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 1/5] t3701-add-interactive: simplify code Matthieu Moy
                         ` (4 more replies)
  5 siblings, 5 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

Change since v2: simplify the code (for consistancy, I also changed
the code I copy/pasted from in a separate patch).

Still out of Git time budget though :-(.

Matthieu Moy (5):
  t3701-add-interactive: simplify code
  add -p: demonstrate failure when running 'edit' after a split
  t3904-stash-patch: fix test description
  t3904-stash-patch: factor PERL prereq at the top of the file
  stash -p: demonstrate failure of split with mixed y/n

 t/t3701-add-interactive.sh | 27 +++++++++++++++++++++++----
 t/t3904-stash-patch.sh     | 43 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 59 insertions(+), 11 deletions(-)

-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/5] t3701-add-interactive: simplify code
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
@ 2015-04-16  7:02       ` Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 2/5] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3701-add-interactive.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 24ddd8a..b63b9d4 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -326,10 +326,7 @@ test_expect_success 'split hunk "add -p (edit)"' '
 	# 2. Correct version applies the (not)edited version, and asks
 	#    about the next hunk, against which we say q and program
 	#    exits.
-	for a in s e     q n q q
-	do
-		echo $a
-	done |
+	printf "%s\n" s e     q n q q |
 	EDITOR=: git add -p &&
 	git diff >actual &&
 	! grep "^+15" actual
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/5] add -p: demonstrate failure when running 'edit' after a split
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 1/5] t3701-add-interactive: simplify code Matthieu Moy
@ 2015-04-16  7:02       ` Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 3/5] t3904-stash-patch: fix test description Matthieu Moy
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

The test passes if one replaces the 'e' command with a 'y' command in
the 'add -p' session.

Reported-by: Tanky Woo <wtq1990@gmail.com>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3701-add-interactive.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index b63b9d4..deae948 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -332,6 +332,28 @@ test_expect_success 'split hunk "add -p (edit)"' '
 	! grep "^+15" actual
 '
 
+test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
+	cat >test <<-\EOF &&
+	5
+	10
+	20
+	21
+	30
+	31
+	40
+	50
+	60
+	EOF
+	git reset &&
+	# test sequence is s(plit), n(o), y(es), e(dit)
+	# q n q q is there to make sure we exit at the end.
+	printf "%s\n" s n y e   q n q q |
+	EDITOR=: git add -p 2>error &&
+	test_must_be_empty error &&
+	git diff >actual &&
+	! grep "^+31" actual
+'
+
 test_expect_success 'patch mode ignores unmerged entries' '
 	git reset --hard &&
 	test_commit conflict &&
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/5] t3904-stash-patch: fix test description
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 1/5] t3701-add-interactive: simplify code Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 2/5] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
@ 2015-04-16  7:02       ` Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 4/5] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 5/5] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
  4 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

The old description is rather clearly a wrong cut-and-paste from
t2016-checkout-patch.sh.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 70655c1..9a59683 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-test_description='git checkout --patch'
+test_description='stash -p'
 . ./lib-patch-mode.sh
 
 test_expect_success PERL 'setup' '
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 4/5] t3904-stash-patch: factor PERL prereq at the top of the file
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
                         ` (2 preceding siblings ...)
  2015-04-16  7:02       ` [PATCH v2 3/5] t3904-stash-patch: fix test description Matthieu Moy
@ 2015-04-16  7:02       ` Matthieu Moy
  2015-04-16  7:02       ` [PATCH v2 5/5] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
  4 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 9a59683..0f8f47f 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -3,7 +3,13 @@
 test_description='stash -p'
 . ./lib-patch-mode.sh
 
-test_expect_success PERL 'setup' '
+if ! test_have_prereq PERL
+then
+	skip_all='skipping stash -p tests, perl not available'
+	test_done
+fi
+
+test_expect_success 'setup' '
 	mkdir dir &&
 	echo parent > dir/foo &&
 	echo dummy > bar &&
@@ -20,7 +26,7 @@ test_expect_success PERL 'setup' '
 
 # note: order of files with unstaged changes: HEAD bar dir/foo
 
-test_expect_success PERL 'saying "n" does nothing' '
+test_expect_success 'saying "n" does nothing' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state dir/foo work index &&
 	(echo n; echo n; echo n) | test_must_fail git stash save -p &&
@@ -29,7 +35,7 @@ test_expect_success PERL 'saying "n" does nothing' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'git stash -p' '
+test_expect_success 'git stash -p' '
 	(echo y; echo n; echo y) | git stash save -p &&
 	verify_state HEAD committed HEADfile_index &&
 	verify_saved_state bar &&
@@ -41,7 +47,7 @@ test_expect_success PERL 'git stash -p' '
 	verify_state dir/foo work head
 '
 
-test_expect_success PERL 'git stash -p --no-keep-index' '
+test_expect_success 'git stash -p --no-keep-index' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state bar bar_work bar_index &&
 	set_state dir/foo work index &&
@@ -56,7 +62,7 @@ test_expect_success PERL 'git stash -p --no-keep-index' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'git stash --no-keep-index -p' '
+test_expect_success 'git stash --no-keep-index -p' '
 	set_state HEAD HEADfile_work HEADfile_index &&
 	set_state bar bar_work bar_index &&
 	set_state dir/foo work index &&
@@ -71,7 +77,7 @@ test_expect_success PERL 'git stash --no-keep-index -p' '
 	verify_state dir/foo work index
 '
 
-test_expect_success PERL 'none of this moved HEAD' '
+test_expect_success 'none of this moved HEAD' '
 	verify_saved_head
 '
 
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 5/5] stash -p: demonstrate failure of split with mixed y/n
  2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
                         ` (3 preceding siblings ...)
  2015-04-16  7:02       ` [PATCH v2 4/5] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
@ 2015-04-16  7:02       ` Matthieu Moy
  4 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2015-04-16  7:02 UTC (permalink / raw)
  To: gitster; +Cc: git, Eric Sunshine, Tanky Woo, Matthieu Moy

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t3904-stash-patch.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 0f8f47f..38e7300 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -81,4 +81,27 @@ test_expect_success 'none of this moved HEAD' '
 	verify_saved_head
 '
 
+test_expect_failure 'stash -p with split hunk' '
+	git reset --hard &&
+	cat >test <<-\EOF &&
+	aaa
+	bbb
+	ccc
+	EOF
+	git add test &&
+	git commit -m "initial" &&
+	cat >test <<-\EOF &&
+	aaa
+	added line 1
+	bbb
+	added line 2
+	ccc
+	EOF
+	printf "%s\n" s n y q |
+	test_might_fail git stash -p 2>error &&
+	! test_must_be_empty error &&
+	grep "added line 1" test &&
+	! grep "added line 2" test
+'
+
 test_done
-- 
2.4.0.rc1.42.g9642cc6

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-04-16  7:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-14  1:56 Git add -p “Your edited hunk does not apply. Edit again” Tanky Woo
2015-04-14  9:43 ` Matthieu Moy
2015-04-14 11:32   ` [PATCH 0/4] demonstrate add -p and stash -p failures Matthieu Moy
2015-04-14 11:32     ` [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
2015-04-14 20:46       ` Eric Sunshine
2015-04-14 11:32     ` [PATCH 2/4] t3904-stash-patch: fix test description Matthieu Moy
2015-04-14 11:32     ` [PATCH 3/4] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
2015-04-14 11:32     ` [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
2015-04-14 20:46       ` Eric Sunshine
2015-04-14 18:00     ` [PATCH 0/4] demonstrate add -p and stash -p failures Junio C Hamano
2015-04-16  7:02     ` [PATCH v2 0/5] " Matthieu Moy
2015-04-16  7:02       ` [PATCH v2 1/5] t3701-add-interactive: simplify code Matthieu Moy
2015-04-16  7:02       ` [PATCH v2 2/5] add -p: demonstrate failure when running 'edit' after a split Matthieu Moy
2015-04-16  7:02       ` [PATCH v2 3/5] t3904-stash-patch: fix test description Matthieu Moy
2015-04-16  7:02       ` [PATCH v2 4/5] t3904-stash-patch: factor PERL prereq at the top of the file Matthieu Moy
2015-04-16  7:02       ` [PATCH v2 5/5] stash -p: demonstrate failure of split with mixed y/n Matthieu Moy
     [not found]   ` <CALv9gbMshdNhB58Otx5h8rmtCAU4qo9eNTqKSMzD_Phy7Sataw@mail.gmail.com>
2015-04-14 14:00     ` Git add -p “Your edited hunk does not apply. Edit again” Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).