git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git add -p “Your edited hunk does not apply. Edit again”

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Apr 14, 2015, 09:43 UTC
Message-ID
<vpq7ftfkpue.fsf@anie.imag.fr>
In-Reply-To
<loom.20150414T035141-286@post.gmane.org>
Tanky Woo <wtq1990@gmail.com> writes:
Show 8 quoted lines
> -       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/
Previous: Tanky WooNext: Matthieu Moy
Message 2 of 17 in “Git add -p “Your edited hunk does not apply. Edit again””
  1. Tanky WooApr 14, 2015
  2. Matthieu MoyApr 14, 2015
  3. 0/4 demonstrate add -p and stash -p failures.Matthieu Moy, Apr 14, 2015
  4. 1/4 add -p: demonstrate failure when running 'edit' after a splitMatthieu Moy, Apr 14, 2015
  5. Eric SunshineApr 14, 2015
  6. 2/4 t3904-stash-patch: fix test descriptionMatthieu Moy, Apr 14, 2015
  7. 3/4 t3904-stash-patch: factor PERL prereq at the top of the fileMatthieu Moy, Apr 14, 2015
  8. 4/4 stash -p: demonstrate failure of split with mixed y/nMatthieu Moy, Apr 14, 2015
  9. Eric SunshineApr 14, 2015
  10. Junio C HamanoApr 14, 2015
  11. 0/5 demonstrate add -p and stash -p failuresMatthieu Moy, Apr 16, 2015
  12. 1/5 t3701-add-interactive: simplify codeMatthieu Moy, Apr 16, 2015
  13. 2/5 add -p: demonstrate failure when running 'edit' after a splitMatthieu Moy, Apr 16, 2015
  14. 3/5 t3904-stash-patch: fix test descriptionMatthieu Moy, Apr 16, 2015
  15. 4/5 t3904-stash-patch: factor PERL prereq at the top of the fileMatthieu Moy, Apr 16, 2015
  16. 5/5 stash -p: demonstrate failure of split with mixed y/nMatthieu Moy, Apr 16, 2015
  17. Matthieu MoyApr 14, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.