{"thread":{"id":"39067","subject":"Git add -p “Your edited hunk does not apply. Edit again”","startedAt":"2015-04-14T01:56:12Z","lastAt":"2015-04-16T07:02:31Z","messageCount":17,"participants":["Tanky Woo","Matthieu Moy","Junio C Hamano","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"259318","messageId":"loom.20150414T035141-286@post.gmane.org","threadId":"39067","inReplyTo":null,"subject":"Git add -p “Your edited hunk does not apply. Edit again”","fromName":"Tanky Woo","fromEmail":"wtq1990@gmail.com","sentAt":"2015-04-14T01:56:12Z","receivedAt":"2015-04-14T01:56:12Z","isPatch":false,"sender":{"key":"wtq1990@gmail.com","avatar":null},"body":"I asked this question in stackoverflow a few days ago, but get no answer.\n\nlink: http://stackoverflow.com/questions/29518944/git-add-p-your-edited-hunk-does-not-apply-\nedit-again\n\n---\n\nAn example, the original file:\n\ntest:\n       make clean\n       nosetests\n\nclean:\n       rm -rf htmlcov\n       rm -rf build dist\n       coverage erase\nThe file after changed:\n\nHTMLCOV=\"htmlcov/\"\n\ntest:\n       make clean\n       nosetests\n\nclean:\n       coverage erase\n       rm -rf htmlcov\n       rm -rf build dist\n\ncovhtml:\n       make clean\n       nosetests\n       coverage html\n       cd ${HTMLCOV} && python -m SimpleHTTPServer\nThis is the diff:\n\ndiff --git a/mf b/mf\nindex b9ca06e..6316e17 100644\n--- a/mf\n+++ b/mf\n@@ -1,8 +1,16 @@\n+HTMLCOV=\"htmlcov/\"            # Hunk 1\n+\n test:\n        make clean\n        nosetests\n\n clean:\n+       coverage erase         # Hunk 2\n        rm -rf htmlcov\n        rm -rf build dist\n-       coverage erase         # Hunk 3\n+\n+covhtml:\n+       make clean\n+       nosetests\n+       coverage html\n+       cd ${HTMLCOV} && python -m SimpleHTTPServer\nI use git add -p, want only to add:\n\n+       coverage erase\n        rm -rf htmlcov\n        rm -rf build dist\n-       coverage erase\nSo I first use s to split hunks, and n to ignore first add,\nthen use y to add second hunk, the third hunk \nis:\n\n-       coverage erase\n+\n+covhtml:\n+       make clean\n+       nosetests\n+       coverage html\n+       cd ${HTMLCOV} && python -m SimpleHTTPServer\nSo I use e to manually edit the hunk, I delete all the + lines, it seems:\n\n# Manual hunk edit mode -- see bottom for a quick guide\n@@ -6,3 +9,8 @@\n        rm -rf htmlcov\n        rm -rf build dist\n-       coverage erase\n# ---\n# To remove '-' lines, make them ' ' lines (context).\n# To remove '+' lines, delete them.\n# Lines starting with # will be removed.\n#\n# ....\nBut when I saved, it says:\n\n@@ -6,3 +9,8 @@\n        rm -rf htmlcov\n        rm -rf build dist\n-       coverage erase\n+\n+covhtml:\n+       make clean\n+       nosetests\n+       coverage html\n+       cd ${HTMLCOV} && python -m SimpleHTTPServer\nStage this hunk [y,n,q,a,d,/,K,g,e,?]? e\nerror: patch failed: mf:1\nerror: mf: patch does not apply\nYour edited hunk does not apply. Edit again (saying \"no\" discards!) [y/n]?\nAnd then I change to @@ from-file-range to-file-range @@ part to:\n\n@@ -6,3 +9,2 @@\nThere is still the same problem.\n\nIf I first add only the second Hunk, \nand then I run git add -p xxx again, and edit the hunk, \nthere is no problem. Why?\n"},{"id":"259337","messageId":"vpq7ftfkpue.fsf@anie.imag.fr","threadId":"39067","inReplyTo":"loom.20150414T035141-286@post.gmane.org","subject":"Re: Git add -p “Your edited hunk does not apply. Edit again”","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-04-14T09:43:05Z","receivedAt":"2015-04-14T09:43:05Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Tanky Woo <wtq1990@gmail.com> writes:\n\n> -       coverage erase\n> +\n> +covhtml:\n> +       make clean\n> +       nosetests\n> +       coverage html\n> +       cd ${HTMLCOV} && python -m SimpleHTTPServer\n> So I use e to manually edit the hunk, I delete all the + lines, it seems:\n\nI can reproduce on git.git's master. Actually, you don't even have to\nedit the patch, just save and exit, and you get the same error message.\nSo it's clearly a bug.\n\nI can get the same kind of bug with \"stash -p\", without even using the\n'e' command, by doing \"split\" and then answer n, y. On a simpler example\nwith two hunks:\n\n$ git stash -p\ndiff --git a/bar.txt b/bar.txt\nindex 35fbd83..1d3fda3 100644\n--- a/bar.txt\n+++ b/bar.txt\n@@ -1,4 +1,6 @@\n aaa\n+added line 1\n bbb\n+added line 2\n ccc\n ddd\nStash this hunk [y,n,q,a,d,/,s,e,?]? s\nSplit into 2 hunks.\n@@ -1,2 +1,3 @@\n aaa\n+added line 1\n bbb\nStash this hunk [y,n,q,a,d,/,j,J,g,e,?]? n\n@@ -2,3 +3,4 @@\n bbb\n+added line 2\n ccc\n ddd\nStash this hunk [y,n,q,a,d,/,K,g,e,?]? y\n\nSaved working directory and index state WIP on master: 1cad001 abcd\nerror: patch failed: bar.txt:1\nerror: bar.txt: patch does not apply\nCannot remove worktree changes\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"259343","messageId":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"vpq7ftfkpue.fsf@anie.imag.fr","subject":"[PATCH 0/4] demonstrate add -p and stash -p failures.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-14T11:32:44Z","receivedAt":"2015-04-14T11:32:44Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Playing a bit with add -p and stash -p, I can confirm the bug reported\nby Tanky. This series just adds failing tests, but I couldn't debug it.\n\nI've exhausted my Git time budget for now, so if someone wants to take\nover and fix the bugs, feel free to do it!\n\nMatthieu Moy (4):\n  add -p: demonstrate failure when running 'edit' after a split\n  t3904-stash-patch: fix test description\n  t3904-stash-patch: factor PERL prereq at the top of the file\n  stash -p: demonstrate failure of split with mixed y/n\n\n t/t3701-add-interactive.sh | 25 +++++++++++++++++++++++++\n t/t3904-stash-patch.sh     | 46 +++++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 64 insertions(+), 7 deletions(-)\n\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259345","messageId":"1429011168-23216-2-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-14T11:32:45Z","receivedAt":"2015-04-14T11:32:45Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The test passes if one replaces the 'e' command with a 'y' command in\nthe 'add -p' session.\n\nReported-by: Tanky Woo <wtq1990@gmail.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3701-add-interactive.sh | 25 +++++++++++++++++++++++++\n 1 file changed, 25 insertions(+)\n\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 24ddd8a..b48a75c 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -335,6 +335,31 @@ test_expect_success 'split hunk \"add -p (edit)\"' '\n \t! grep \"^+15\" actual\n '\n \n+test_expect_failure 'split hunk \"add -p (no, yes, edit)\"' '\n+\tcat >test <<-\\EOF &&\n+\t5\n+\t10\n+\t20\n+\t21\n+\t30\n+\t31\n+\t40\n+\t50\n+\t60\n+\tEOF\n+\tgit reset &&\n+\t# test sequence is s(plit), n(o), y(es), e(dit)\n+\t# q n q q is there to make sure we exit at the end.\n+\tfor a in s n y e   q n q q\n+\tdo\n+\t\techo $a\n+\tdone |\n+\tEDITOR=: git add -p 2>error &&\n+\ttest_must_be_empty error &&\n+\tgit diff >actual &&\n+\t! grep \"^+31\" actual\n+'\n+\n test_expect_success 'patch mode ignores unmerged entries' '\n \tgit reset --hard &&\n \ttest_commit conflict &&\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259341","messageId":"1429011168-23216-3-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 2/4] t3904-stash-patch: fix test description","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-14T11:32:46Z","receivedAt":"2015-04-14T11:32:46Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The old description is rather clearly a wrong cut-and-paste from\nt2016-checkout-patch.sh.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 70655c1..9a59683 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-test_description='git checkout --patch'\n+test_description='stash -p'\n . ./lib-patch-mode.sh\n \n test_expect_success PERL 'setup' '\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259342","messageId":"1429011168-23216-4-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 3/4] t3904-stash-patch: factor PERL prereq at the top of the file","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-14T11:32:47Z","receivedAt":"2015-04-14T11:32:47Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 18 ++++++++++++------\n 1 file changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 9a59683..0f8f47f 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -3,7 +3,13 @@\n test_description='stash -p'\n . ./lib-patch-mode.sh\n \n-test_expect_success PERL 'setup' '\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping stash -p tests, perl not available'\n+\ttest_done\n+fi\n+\n+test_expect_success 'setup' '\n \tmkdir dir &&\n \techo parent > dir/foo &&\n \techo dummy > bar &&\n@@ -20,7 +26,7 @@ test_expect_success PERL 'setup' '\n \n # note: order of files with unstaged changes: HEAD bar dir/foo\n \n-test_expect_success PERL 'saying \"n\" does nothing' '\n+test_expect_success 'saying \"n\" does nothing' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state dir/foo work index &&\n \t(echo n; echo n; echo n) | test_must_fail git stash save -p &&\n@@ -29,7 +35,7 @@ test_expect_success PERL 'saying \"n\" does nothing' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'git stash -p' '\n+test_expect_success 'git stash -p' '\n \t(echo y; echo n; echo y) | git stash save -p &&\n \tverify_state HEAD committed HEADfile_index &&\n \tverify_saved_state bar &&\n@@ -41,7 +47,7 @@ test_expect_success PERL 'git stash -p' '\n \tverify_state dir/foo work head\n '\n \n-test_expect_success PERL 'git stash -p --no-keep-index' '\n+test_expect_success 'git stash -p --no-keep-index' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state bar bar_work bar_index &&\n \tset_state dir/foo work index &&\n@@ -56,7 +62,7 @@ test_expect_success PERL 'git stash -p --no-keep-index' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'git stash --no-keep-index -p' '\n+test_expect_success 'git stash --no-keep-index -p' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state bar bar_work bar_index &&\n \tset_state dir/foo work index &&\n@@ -71,7 +77,7 @@ test_expect_success PERL 'git stash --no-keep-index -p' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'none of this moved HEAD' '\n+test_expect_success 'none of this moved HEAD' '\n \tverify_saved_head\n '\n \n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259344","messageId":"1429011168-23216-5-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-14T11:32:48Z","receivedAt":"2015-04-14T11:32:48Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 26 ++++++++++++++++++++++++++\n 1 file changed, 26 insertions(+)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 0f8f47f..6f053ff 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -81,4 +81,30 @@ test_expect_success 'none of this moved HEAD' '\n \tverify_saved_head\n '\n \n+test_expect_failure 'stash -p with split hunk' '\n+\tgit reset --hard &&\n+\tcat >test <<-\\EOF &&\n+\taaa\n+\tbbb\n+\tccc\n+\tEOF\n+\tgit add test &&\n+\tgit commit -m \"initial\" &&\n+\tcat >test <<-\\EOF &&\n+\taaa\n+\tadded line 1\n+\tbbb\n+\tadded line 2\n+\tccc\n+\tEOF\n+\tfor a in s n y q\n+\tdo\n+\t\techo $a\n+\tdone |\n+\ttest_might_fail git stash -p 2>error &&\n+\t! test_must_be_empty error &&\n+\tgrep \"added line 1\" test &&\n+\t! grep \"added line 2\" test\n+'\n+\n test_done\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259349","messageId":"vpqegnmizce.fsf@anie.imag.fr","threadId":"39067","inReplyTo":"CALv9gbMshdNhB58Otx5h8rmtCAU4qo9eNTqKSMzD_Phy7Sataw@mail.gmail.com","subject":"Re: Git add -p “Your edited hunk does not apply. Edit again”","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-04-14T14:00:49Z","receivedAt":"2015-04-14T14:00:49Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Tanky Woo <wtq1990@gmail.com> writes:\n\n> Stash this hunk [y,n,q,a,d,/,j,J,g,e,?]? y\n> @@ -2,3 +3,4 @@\n>  bbb\n> +added line 2\n>  ccc\n>  ddd\n> Stash this hunk [y,n,q,a,d,/,K,g,e,?]? y\n\nMy version does n, y, not y, y. The problem is the mix of stashed/not\nstashed hunks. See my other message for a reproducible test, it does\nfail on Git master.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"259365","messageId":"xmqqbniq3803.fsf@gitster.dls.corp.google.com","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH 0/4] demonstrate add -p and stash -p failures.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-14T18:00:28Z","receivedAt":"2015-04-14T18:00:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Playing a bit with add -p and stash -p, I can confirm the bug reported\n> by Tanky. This series just adds failing tests, but I couldn't debug it.\n>\n> I've exhausted my Git time budget for now, so if someone wants to take\n> over and fix the bugs, feel free to do it!\n\nI do not have time to dig this either for now, but I suspect this\n\"split a hunk into two overlapping hunks\" issue may be related to\nthe caveat in the very original:\n\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/76650/focus=87197\n\n\nwhere I seem to have said that the proposed change would make \"add\n-p\" less robust than the original code (even without 'e'dit):\n\n    Junio C Hamano wrote:\n    > \n    > I recall that the original \"add--interactive\" carefully counted\n    > numbers in hunks it reassembles (as it can let you split and then\n    > you can choose to use both parts, which requires it to merge\n    > overlapping hunks back), but if you are going to use --recount\n    > anyway, perhaps we can discard that logic?  It may make the patch\n    > application less robust, though.  I dunno.\n\n\nIt seems that we accepted that series saying \"let's see what\nhappens\" at the end, and I suspect we are seeing its consequences\n;-).\n"},{"id":"259371","messageId":"CAPig+cQQrWUESdOdVCS_sU+muttt=P+sRJBjzrWTEUn10+aSDw@mail.gmail.com","threadId":"39067","inReplyTo":"1429011168-23216-2-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH 1/4] add -p: demonstrate failure when running 'edit' after a split","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-04-14T20:46:09Z","receivedAt":"2015-04-14T20:46:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Apr 14, 2015 at 7:32 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> The test passes if one replaces the 'e' command with a 'y' command in\n> the 'add -p' session.\n>\n> Reported-by: Tanky Woo <wtq1990@gmail.com>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index 24ddd8a..b48a75c 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -335,6 +335,31 @@ test_expect_success 'split hunk \"add -p (edit)\"' '\n>         ! grep \"^+15\" actual\n>  '\n>\n> +test_expect_failure 'split hunk \"add -p (no, yes, edit)\"' '\n> +       cat >test <<-\\EOF &&\n> +       5\n> +       10\n> +       20\n> +       21\n> +       30\n> +       31\n> +       40\n> +       50\n> +       60\n> +       EOF\n> +       git reset &&\n> +       # test sequence is s(plit), n(o), y(es), e(dit)\n> +       # q n q q is there to make sure we exit at the end.\n> +       for a in s n y e   q n q q\n> +       do\n> +               echo $a\n> +       done |\n\nSimplified:\n\n    printf '%s\\n' s n y e q n q q |\n\n> +       EDITOR=: git add -p 2>error &&\n> +       test_must_be_empty error &&\n> +       git diff >actual &&\n> +       ! grep \"^+31\" actual\n> +'\n> +\n>  test_expect_success 'patch mode ignores unmerged entries' '\n>         git reset --hard &&\n>         test_commit conflict &&\n> --\n> 2.4.0.rc1.42.g9642cc6\n"},{"id":"259372","messageId":"CAPig+cQSyjNSxixEOVjR1CTTzPfT5kT9sbdGMLa1n3K_1zEHfA@mail.gmail.com","threadId":"39067","inReplyTo":"1429011168-23216-5-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH 4/4] stash -p: demonstrate failure of split with mixed y/n","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-04-14T20:46:15Z","receivedAt":"2015-04-14T20:46:15Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Apr 14, 2015 at 7:32 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n> diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\n> index 0f8f47f..6f053ff 100755\n> --- a/t/t3904-stash-patch.sh\n> +++ b/t/t3904-stash-patch.sh\n> @@ -81,4 +81,30 @@ test_expect_success 'none of this moved HEAD' '\n>         verify_saved_head\n>  '\n>\n> +test_expect_failure 'stash -p with split hunk' '\n> +       git reset --hard &&\n> +       cat >test <<-\\EOF &&\n> +       aaa\n> +       bbb\n> +       ccc\n> +       EOF\n> +       git add test &&\n> +       git commit -m \"initial\" &&\n> +       cat >test <<-\\EOF &&\n> +       aaa\n> +       added line 1\n> +       bbb\n> +       added line 2\n> +       ccc\n> +       EOF\n> +       for a in s n y q\n> +       do\n> +               echo $a\n> +       done |\n\nSimplified:\n\n    printf '%s\\n' s n y q |\n\n> +       test_might_fail git stash -p 2>error &&\n> +       ! test_must_be_empty error &&\n> +       grep \"added line 1\" test &&\n> +       ! grep \"added line 2\" test\n> +'\n> +\n>  test_done\n> --\n> 2.4.0.rc1.42.g9642cc6\n"},{"id":"259464","messageId":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429011168-23216-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 0/5] demonstrate add -p and stash -p failures","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:26Z","receivedAt":"2015-04-16T07:02:26Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Change since v2: simplify the code (for consistancy, I also changed\nthe code I copy/pasted from in a separate patch).\n\nStill out of Git time budget though :-(.\n\nMatthieu Moy (5):\n  t3701-add-interactive: simplify code\n  add -p: demonstrate failure when running 'edit' after a split\n  t3904-stash-patch: fix test description\n  t3904-stash-patch: factor PERL prereq at the top of the file\n  stash -p: demonstrate failure of split with mixed y/n\n\n t/t3701-add-interactive.sh | 27 +++++++++++++++++++++++----\n t/t3904-stash-patch.sh     | 43 ++++++++++++++++++++++++++++++++++++-------\n 2 files changed, 59 insertions(+), 11 deletions(-)\n\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259460","messageId":"1429167751-19398-2-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 1/5] t3701-add-interactive: simplify code","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:27Z","receivedAt":"2015-04-16T07:02:27Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3701-add-interactive.sh | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 24ddd8a..b63b9d4 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -326,10 +326,7 @@ test_expect_success 'split hunk \"add -p (edit)\"' '\n \t# 2. Correct version applies the (not)edited version, and asks\n \t#    about the next hunk, against which we say q and program\n \t#    exits.\n-\tfor a in s e     q n q q\n-\tdo\n-\t\techo $a\n-\tdone |\n+\tprintf \"%s\\n\" s e     q n q q |\n \tEDITOR=: git add -p &&\n \tgit diff >actual &&\n \t! grep \"^+15\" actual\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259461","messageId":"1429167751-19398-3-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 2/5] add -p: demonstrate failure when running 'edit' after a split","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:28Z","receivedAt":"2015-04-16T07:02:28Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The test passes if one replaces the 'e' command with a 'y' command in\nthe 'add -p' session.\n\nReported-by: Tanky Woo <wtq1990@gmail.com>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3701-add-interactive.sh | 22 ++++++++++++++++++++++\n 1 file changed, 22 insertions(+)\n\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex b63b9d4..deae948 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -332,6 +332,28 @@ test_expect_success 'split hunk \"add -p (edit)\"' '\n \t! grep \"^+15\" actual\n '\n \n+test_expect_failure 'split hunk \"add -p (no, yes, edit)\"' '\n+\tcat >test <<-\\EOF &&\n+\t5\n+\t10\n+\t20\n+\t21\n+\t30\n+\t31\n+\t40\n+\t50\n+\t60\n+\tEOF\n+\tgit reset &&\n+\t# test sequence is s(plit), n(o), y(es), e(dit)\n+\t# q n q q is there to make sure we exit at the end.\n+\tprintf \"%s\\n\" s n y e   q n q q |\n+\tEDITOR=: git add -p 2>error &&\n+\ttest_must_be_empty error &&\n+\tgit diff >actual &&\n+\t! grep \"^+31\" actual\n+'\n+\n test_expect_success 'patch mode ignores unmerged entries' '\n \tgit reset --hard &&\n \ttest_commit conflict &&\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259462","messageId":"1429167751-19398-4-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 3/5] t3904-stash-patch: fix test description","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:29Z","receivedAt":"2015-04-16T07:02:29Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The old description is rather clearly a wrong cut-and-paste from\nt2016-checkout-patch.sh.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 70655c1..9a59683 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-test_description='git checkout --patch'\n+test_description='stash -p'\n . ./lib-patch-mode.sh\n \n test_expect_success PERL 'setup' '\n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259463","messageId":"1429167751-19398-5-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 4/5] t3904-stash-patch: factor PERL prereq at the top of the file","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:30Z","receivedAt":"2015-04-16T07:02:30Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 18 ++++++++++++------\n 1 file changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 9a59683..0f8f47f 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -3,7 +3,13 @@\n test_description='stash -p'\n . ./lib-patch-mode.sh\n \n-test_expect_success PERL 'setup' '\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping stash -p tests, perl not available'\n+\ttest_done\n+fi\n+\n+test_expect_success 'setup' '\n \tmkdir dir &&\n \techo parent > dir/foo &&\n \techo dummy > bar &&\n@@ -20,7 +26,7 @@ test_expect_success PERL 'setup' '\n \n # note: order of files with unstaged changes: HEAD bar dir/foo\n \n-test_expect_success PERL 'saying \"n\" does nothing' '\n+test_expect_success 'saying \"n\" does nothing' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state dir/foo work index &&\n \t(echo n; echo n; echo n) | test_must_fail git stash save -p &&\n@@ -29,7 +35,7 @@ test_expect_success PERL 'saying \"n\" does nothing' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'git stash -p' '\n+test_expect_success 'git stash -p' '\n \t(echo y; echo n; echo y) | git stash save -p &&\n \tverify_state HEAD committed HEADfile_index &&\n \tverify_saved_state bar &&\n@@ -41,7 +47,7 @@ test_expect_success PERL 'git stash -p' '\n \tverify_state dir/foo work head\n '\n \n-test_expect_success PERL 'git stash -p --no-keep-index' '\n+test_expect_success 'git stash -p --no-keep-index' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state bar bar_work bar_index &&\n \tset_state dir/foo work index &&\n@@ -56,7 +62,7 @@ test_expect_success PERL 'git stash -p --no-keep-index' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'git stash --no-keep-index -p' '\n+test_expect_success 'git stash --no-keep-index -p' '\n \tset_state HEAD HEADfile_work HEADfile_index &&\n \tset_state bar bar_work bar_index &&\n \tset_state dir/foo work index &&\n@@ -71,7 +77,7 @@ test_expect_success PERL 'git stash --no-keep-index -p' '\n \tverify_state dir/foo work index\n '\n \n-test_expect_success PERL 'none of this moved HEAD' '\n+test_expect_success 'none of this moved HEAD' '\n \tverify_saved_head\n '\n \n-- \n2.4.0.rc1.42.g9642cc6\n"},{"id":"259465","messageId":"1429167751-19398-6-git-send-email-Matthieu.Moy@imag.fr","threadId":"39067","inReplyTo":"1429167751-19398-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH v2 5/5] stash -p: demonstrate failure of split with mixed y/n","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2015-04-16T07:02:31Z","receivedAt":"2015-04-16T07:02:31Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n t/t3904-stash-patch.sh | 23 +++++++++++++++++++++++\n 1 file changed, 23 insertions(+)\n\ndiff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh\nindex 0f8f47f..38e7300 100755\n--- a/t/t3904-stash-patch.sh\n+++ b/t/t3904-stash-patch.sh\n@@ -81,4 +81,27 @@ test_expect_success 'none of this moved HEAD' '\n \tverify_saved_head\n '\n \n+test_expect_failure 'stash -p with split hunk' '\n+\tgit reset --hard &&\n+\tcat >test <<-\\EOF &&\n+\taaa\n+\tbbb\n+\tccc\n+\tEOF\n+\tgit add test &&\n+\tgit commit -m \"initial\" &&\n+\tcat >test <<-\\EOF &&\n+\taaa\n+\tadded line 1\n+\tbbb\n+\tadded line 2\n+\tccc\n+\tEOF\n+\tprintf \"%s\\n\" s n y q |\n+\ttest_might_fail git stash -p 2>error &&\n+\t! test_must_be_empty error &&\n+\tgrep \"added line 1\" test &&\n+\t! grep \"added line 2\" test\n+'\n+\n test_done\n-- \n2.4.0.rc1.42.g9642cc6\n"}]}