-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to stage hunk on Windows when file uses LF (unix) line endings #176
Comments
Could you try #177 patch ? |
@syohex, I tried this patch, and it partially worked, but it lead to a discovery of a more fundamental problem. It appears the format of the patch generated by What I realized is that I had In summary, what I observed with Windows git:
Therefore, it doesn't appear to be enough to base the line termination of the patch file on the workspace file, as that may not be how it is internally represented. Additionally, it appears problematic to attempt to force the line termination a specific way, and it is probably best to preserve the line termination as originally generated by With the currently proposed #177 patch, I can make this fail on Linux in the following manner:
I think if the temporary patch file generation can be changed so that it doesn't perform line ending conversions from the output that |
Mark with |
In a repository which uses LF line termination, using git-gutter on Windows appears to be problematic for staging hunks (and possibly other operations).
Scenario:
M-x git-gutter:stage-hunk
I investigated this a bit and discovered that the temporary "patch" file created in
git-gutter:do-stage-hunk
ends up using CRLF line endings when written to the file system. Note that this patch file is different than if you just performed thegit diff
command directly at the command line as the patch file contains CRLF and thegit diff
command contains only LF endings. Thus, it appears the internal manipulation of the diff output within the Emacs buffers by git-gutter is likely what is causing the line-endings to be changed to CRLF.This trips up the subsequent
git apply
as that is the command which fails (with "patch failed" and "patch does not apply" output from git). I modified the source to prevent the temporary file from being deleted, so that I could experiment with attempting to apply the patch directly with git from the console. I then performed a conversion of the line endings of the patch file (i.e.,dos2unix -U <temp file>
) and repeated thegit apply
command. The subsequentgit apply
then succeeds. So it appears that Windows git is sensitive to the line endings of the patch file created by git-gutter. I looked at the--whitespace=fix
and--ignore-whitespace
options forgit apply
, but neither of those make sense in this scenario.I also attempted to replicate the reverse behavior on Linux. Starting with a CRLF EOL file and performed a git-gutter:stage-hunk on that. The *git-gutter:diff* buffer showed the line ending as being LF, but the subsequent
git apply
succeeded. Thus, this appears to be problematic only on Windows.Steps to reproduce (on Windows):
git-gutter:stage-hunk
to stage the change.These were the versions of tools I used:
The text was updated successfully, but these errors were encountered: