From: Hannu Koivisto <azure@iki.fi>
To: git@vger.kernel.org
Subject: git add --patch bug with split+edit?
Date: Sat, 17 Jan 2009 03:37:43 +0200 [thread overview]
Message-ID: <833afihfvc.fsf@kalahari.s2.org> (raw)
Greetings,
If I have a hunk that adds three lines, I can edit the hunk and
remove the last line but I can't split it in two, stage the first
part, edit the second part and remove the last line. An example:
mkdir gittest
cd gittest
git init
echo "baz\nbaz" > baz
git add baz
git commit -m baz baz
rm baz
echo "sur\nbaz\nbaz\njee\njee" > baz
git add --patch
Now say 's RET y RET e RET' and remove the second "+jee" line using
your editor. The output for me looks like this:
--8<-----------------------------------------------------------------
diff --git a/baz b/baz
index 1f55335..48a5f83 100644
--- a/baz
+++ b/baz
@@ -1,2 +1,5 @@
+sur
baz
baz
+jee
+jee
Stage this hunk [y/n/a/d/s/e/?]? s
Split into 2 hunks.
@@ -1,2 +1,3 @@
+sur
baz
baz
Stage this hunk [y/n/a/d/j/J/e/?]? y
@@ -1,2 +2,4 @@
baz
baz
+jee
+jee
Stage this hunk [y/n/a/d/K/e/?]? e
Waiting for Emacs...
error: patch failed: baz:1
error: baz: patch does not apply
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?
--8<-----------------------------------------------------------------
What I also didn't expect is that if I answer 'n' to that last
question, I get...
@@ -1,2 +1,3 @@
+sur
baz
baz
Stage this hunk [y/n/a/d/j/J/e/?]?
...which is the first part of the splitted hunk that I already
staged. If I answer 'd', git status and git diff indicate that
"+sur" is nevertheless staged.
Now, if instead of splitting the hunk and editing it, I edit the
entire...
@@ -1,2 +1,5 @@
+sur
baz
baz
+jee
+jee
...hunk and remove the last "+jee" line, I get no error.
I'm using git 1.6.1 on Linux.
--
Hannu
next reply other threads:[~2009-01-17 1:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-17 1:37 Hannu Koivisto [this message]
2009-01-17 2:33 ` git add --patch bug with split+edit? Jeff King
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=833afihfvc.fsf@kalahari.s2.org \
--to=azure@iki.fi \
--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