git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] new test fails "add -p" for adds on the top line
@ 2009-05-16  3:10 Matt Graham
  2009-05-16 10:25 ` Nanako Shiraishi
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Graham @ 2009-05-16  3:10 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-05-16 19:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-16  3:10 [PATCH] new test fails "add -p" for adds on the top line Matt Graham
2009-05-16 10:25 ` 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

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).