Splitting a hunk that adds a line at the top fails in "add -p"
Splitting a hunk into two in add -p doesn't work for a diff that adds a new line at the top of the file with other add in the same hunk. Signed-off-by: Matthew Graham <mdg149@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matt Graham committed
May 15, 2009 at 23:10 UTC
f67182bf65b01290a9544e9599ea8255e657e567
1 file changed
+32
t/t3701-add-interactive.sh
+32
@@ -165,4 +165,36 @@ test_expect_success FILEMODE 'stage mode but not hunk' '
165
166
# end of tests disabled when filemode is not usable
167
168
+# Write the patch file with a new line at the top and bottom
169
+cat >patch <<EOF
170
+index 180b47c..b6f2c08 100644
171
+--- a/file
172
++++ b/file
173
+@@ -1,2 +1,4 @@
174
++firstline
175
+ baseline
176
+ content
177
++lastline
178
+EOF
179
+# Expected output, similar to the patch but w/ diff at the top
180
+cat >expected <<EOF
181
+diff --git a/file b/file
182
+index b6f2c08..61b9053 100755
183
+--- a/file
184
++++ b/file
185
+@@ -1,2 +1,4 @@
186
++firstline
187
+ baseline
188
+ content
189
++lastline
190
+EOF
191
+# Test splitting the first patch, then adding both
192
+test_expect_failure 'add first line works' '
193
+ git commit -am "clear local changes" &&
194
+ git apply patch &&
195
+ (echo s; echo y; echo y) | git add -p file &&
196
+ git diff --cached > diff &&
197
+ test_cmp expected diff
198
+'
199
+
200
test_done