-
-
Notifications
You must be signed in to change notification settings - Fork 41
Files with CRLF have whole file highlighted as modified #195
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
Comments
Thanks @mjmeli for reporting the issue! |
@mjmeli Can you post the contents of your .gitattributes file? Also, can you try running the following command from a clean checkout of your code (no changes in the working directory)?
After running this command, are there any files staged for commit? |
I have the same issue. |
I'm seeing this too (in VS 2019 Preview 4), also only in some files, but a significant number. We have no
|
@TeaDrivenDev I was about to add a similar comment about the issue being fixed after changing |
@gnudym You should be able to permanently resolve the issue regardless of the autocrlf setting by the following two steps:
Without the first step, the repository will be sensitive to individual developer configurations, leading to various anomalies including but not limited to the one you observed here. Step 2 applies the new configuration to the full repository at once, which avoids a lengthy and very frustrating period where Git wants to renormalize files every time they are changed. |
I appreciate the workaround of normalizing line endings, but unfortunately this workaround won't work in my situation. To give some context, we regretfully have a large monolithic repository shared by the entire engineering department, so it wouldn't be appropriate for me to change the line endings in every file. Some developers also intentionally use different line endings. It's a mess but it is something I have to work around... Unfortunately I haven't been able to reproduce this in a public repo yet. It doesn't appear as simple as having a file with CRLFs in it. Hopefully someone else is able to provide an example repo. |
Been looking at
The |
@duncansmart That, or libgit2 itself. |
The library is behaving the same way Git does for a given user configuration. The only reason we are forced to use |
Yes, it's surely due to such an inconsistency. Looks like there were some changes recently to libgit2 with how it handles line endings in v0.28.0, and this issue started happening in GitDiffMargin v3.9.1 when libgit2sharp was updated. libgit2 is certainly behaving differently than Git. I'm not sure if it is ultimately a bug or correct behavior on libgit2's part, and I wasn't capable to dig deep enough to confirm, but as a user I see there is a discrepancy. I understand that much of this is stemming from having such a messy repository, but unfortunately since renormalizing can't work for me I've had to revert to an older version. For others with this issue (as I'm sure bad line endings are not rare...), v3.9.0 is the latest version that will not have this behavior. Hopefully this works for you all. |
It seems like an issue with LibGit2Sharp not exposing a diff API that allows the paths of blobs to be passed through to allow git to retrieve the content with the appropriate line-endings ... e.g If you do a Whereas, if you call |
Hmmmnn, I've tried updating LibGit2Sharp to pass |
@duncansmart The |
I took an idea from the fix for #193 (9caca99) and applied this on the relativeFilepath passed to
This causes the Anyone see any problems with doing this? |
That works on my machine too 👍 - you'd need to change |
@mjmeli Would you provide a PR so that we can have a look? |
I would also appreciate the hotfix. Just ase you @mjmeli, I also work on a monolithic repo, with 17k (>20% of all) files having CRLF. |
Hope you don't mind that I've submitted a PR @mjmeli |
Fix #195: Files with CRLF have whole file highlighted as modified.
VS v15.8.8
GitDiffMargin v3.9.2.42
After a recent update, I'm seeing that the whole file is often getting highlighted as modified. This is similar to #82 and #164 but is a new instance as its happening after a recent update, plus those are closed, so I'd thought I'd open a new issue. I see a recent comment in #82 that this started happening after v3.9.1.
It's not happening in all files. The common thread I see between the files that it does happen in is that they have CRLF endings. This is also seen in the related issues.
I've noticed this happens when core.autocrlf is true. If I set it false, the issue goes away. Perhaps the extension is picking git normalizing to LFs and the extension shows a diff from the CRLF in Visual Studio?
The text was updated successfully, but these errors were encountered: