This looks to be the same issue as #1609, but I'm opening a new one since that one is marked as completed.
Description
If a file contains no newline at the end of the file, selective staging of individual lines fails with patch does not apply so long as the end of the file appears in the patch.
It looks like this was also an issue in magit at some point, see https://github.com/magit/magit/issues/1139. However, adding "--ignore-space-change" to cmd in StageApply does not seem to address this issue for me so it looks like there's more to the fix.
Steps to reproduce
Init the test repo and set up the problematic file:
git init
echo -n 'line 1
line 2
line 3' > a
git add a
git commit -m a
echo 'line 1
line 2
line 2.2
line 3' > a
Open the status buffer:
Head: main
Unstaged (1)
M a
@@ -1,3 +1,4 @@
line 1
line 2
-line 3
\ No newline at end of file
+line 2.2
+line 3
Try to stage only the "line 2.2" line (visually select and press s):
fugitive: error: patch failed: a:1
error: a: patch does not apply
This looks to be the same issue as #1609, but I'm opening a new one since that one is marked as completed.
Description
If a file contains no newline at the end of the file, selective staging of individual lines fails with
patch does not apply
so long as the end of the file appears in the patch.It looks like this was also an issue in magit at some point, see https://github.com/magit/magit/issues/1139. However, adding "--ignore-space-change" to
cmd
inStageApply
does not seem to address this issue for me so it looks like there's more to the fix.Steps to reproduce
Init the test repo and set up the problematic file:
Open the status buffer:
Try to stage only the "line 2.2" line (visually select and press s):
Details
The cmd being executed is:
The content of that patch file is:
Specs/setup
OS: MacOS Sonoma 14.5 (also reproduced in Windows 11) Fugitive: 0444df6 (Use nvim vim.ui.open as a fallback, 2024-07-18) Git: v2.45.2 Vim: Neovim v0.10.0