From: Tanky Woo <wtq1990@gmail.com>
To: git@vger.kernel.org
Subject: Git add -p “Your edited hunk does not apply. Edit again”
Date: Tue, 14 Apr 2015 01:56:12 +0000 (UTC) [thread overview]
Message-ID: <loom.20150414T035141-286@post.gmane.org> (raw)
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?
next reply other threads:[~2015-04-14 2:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-14 1:56 Tanky Woo [this message]
2015-04-14 9:43 ` Git add -p “Your edited hunk does not apply. Edit again” 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20150414T035141-286@post.gmane.org \
--to=wtq1990@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).