git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Graham <mdg149@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] new test fails "add -p" for adds on the top line
Date: Fri, 15 May 2009 23:10:19 -0400	[thread overview]
Message-ID: <1c5969370905152010m486a8b85s96334e99e6c54ad5@mail.gmail.com> (raw)

add -p doesn't work for some diffs.  diffs adding a new line at the top of
the file with other adds later in the file are one way to trigger the problem.

during add -p, split the diff and then answer y for all segments.  the file
won't have been added to the index.

Signed-off-by: Matthew Graham <mdg149@gmail.com>
---
 t/t3701-add-interactive.sh |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index dfc6560..45da6c8 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -163,6 +163,38 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
 	git diff          file | grep "+content"
 '

+# Write the patch file with a new line at the top and bottom
+cat >patch <<EOF
+index 180b47c..b6f2c08 100644
+--- a/file
++++ b/file
+@@ -1,2 +1,4 @@
++firstline
+ baseline
+ content
++lastline
+EOF
+# Expected output, similar to the patch but w/ diff at the top
+cat >expected <<EOF
+diff --git a/file b/file
+index b6f2c08..61b9053 100755
+--- a/file
++++ b/file
+@@ -1,2 +1,4 @@
++firstline
+ baseline
+ content
++lastline
+EOF
+# Test splitting the first patch, then adding both
+test_expect_failure 'add first line works' '
+	git commit -am "clear local changes" &&
+	git apply patch &&
+	(echo s; echo y; echo y) | git add -p file &&
+	git diff --cached > diff &&
+	test_cmp expected diff
+'
+
 # end of tests disabled when filemode is not usable

 test_done
-- 
1.6.3.9.g6345

             reply	other threads:[~2009-05-16  3:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-16  3:10 Matt Graham [this message]
2009-05-16 10:25 ` [PATCH] new test fails "add -p" for adds on the top line Nanako Shiraishi
2009-05-16 14:12   ` Thomas Rast
2009-05-16 17:48     ` Junio C Hamano
2009-05-16 17:55       ` Sverre Rabbelier
2009-05-16 19:13         ` Junio C Hamano
2009-05-16 19:14           ` Sverre Rabbelier
2009-05-16 19:51       ` Junio C Hamano

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=1c5969370905152010m486a8b85s96334e99e6c54ad5@mail.gmail.com \
    --to=mdg149@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).