Given a file with contents:
foo
bar
baz
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
bar
baz
When I edit this file to become
foo
bar1
baz
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
bar1
baz
(replaced bar
s with bar1
s)
When I run git add --patch
and edit the first hunk
@@ -1,5 +1,5 @@
foo
-bar
+bar1
baz
foo
To become
@@ -1,5 +1,5 @@
foo
-bar
+bar2
baz
foo
(replaced +bar1
with +bar2
)
I get the following error
error: patch fragment without header at line 12: @@ -15,5 +15,5 @@ foo
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?
It is not clear to me why this edit would fail.
Git version: 2.17.0
This appears to be a regression in 2.17.0.
I filed this issue on the Git mailing list and the community there kindly helped me identity the issue.
My question: https://public-inbox.org/git/[email protected]/
The answer: https://public-inbox.org/git/[email protected]/
The problem turned out to be that my editor was trimming trailing whitespace from context lines when editing the hunks. In this example it was the space on the empty line between baz
and foo
.
This appears to be a change in behaviour since Git 2.17.0, as explained in this email: https://public-inbox.org/git/[email protected]/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With