git add -p breaks after split on change at the top of the file
- From
Simon Ruderich <simon@ruderich.org>
- Date
- Aug 16, 2017, 20:25 UTC
- Message-ID
- <20170816202442.aumzwa443spqgyul@ruderich.org>
Hello,
The following session reproduces the issue with Git 2.14.1:
$ git init test
$ cd test
$ echo x >file
$ git add file
$ git commit -m commit
$ printf 'a\nb\nx\nc\n' >file $ git add -p
diff --git a/file b/file
index 587be6b..74a69a0 100644
--- a/file
+++ b/file
@@ -1 +1,4 @@
+a
+b
x
+c
Stage this hunk [y,n,q,a,d,/,s,e,?]? <-- press s
Split into 2 hunks.
@@ -1 +1,3 @@
+a
+b
x
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? <-- press eNow delete the line "+a" in your editor and save.
error: patch failed: file:1
error: file: patch does not applyI expected git add -p to stage this change without error. It works fine without splitting the hunk (by deleting the first and last + line in the diff).
Regards Simon
-- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9