Skip to content
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

CRLF detection fails for files checked in with CRLF line endings #24

Closed
ricksladkey opened this issue Jan 20, 2014 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@ricksladkey
Copy link
Contributor

With v1.3 if:

  • The checked in file in the repository actually contains CRLF line endings and
  • The repository has core.autocrlf=true

then GitDiffMargin will show the entire file as a having been changed. This happens whether the file in the repository is "denormalized" (has the text attribute) or whether it is by design (the file has the -text attribute).

In git, if the .gitattributes file specifies that a given file or files is not text (via the -text specifier), then no end of line conversion will be performed on that file.

Ironically, the GitDiffMargin repository itself contains some denormalized files, i.e. checked in with CRLF line endings, as can be seen by checking the repository out in Linux:

BackgroundParser.cs:                       UTF-8 Unicode (with BOM) C program text
DiffAdditionEditorFormatDefinition.cs:     UTF-8 Unicode (with BOM) C++ program text
DiffModificationEditorFormatDefinition.cs: UTF-8 Unicode (with BOM) C++ program text
DiffParseResultEventArgs.cs:               UTF-8 Unicode (with BOM) C++ program text
DiffRemovedEditorFormatDefinition.cs:      UTF-8 Unicode (with BOM) C++ program text
DiffUpdateBackgroundParser.cs:             UTF-8 Unicode (with BOM) C++ program text, with CRLF line terminators
Extensions.cs:                             UTF-8 Unicode (with BOM) C++ program text
GitDiffMargin.cs:                          UTF-8 Unicode (with BOM) C++ program text, with CRLF line terminators
GitDiffMarginFactory.cs:                   UTF-8 Unicode (with BOM) C++ program text, with CRLF line terminators
GitDiffMarginTextViewOptions.cs:           UTF-8 Unicode (with BOM) C++ program text
ParseResultEventArgs.cs:                   UTF-8 Unicode (with BOM) C program text
WeakReference.cs:                          UTF-8 Unicode (with BOM) C program text
@laurentkempe
Copy link
Owner

There I am not really sure what to do! any idea?

@ricksladkey
Copy link
Contributor Author

It does not appear that Libgit2Sharp yet supports the lower level libgit2 git_attr_get API. That call is needed to find out whether a particular file has the text attribute by inspecting .gitattributes files in the repository.

In the absence of an attribute API, the only reliable way to find out is to actually retrieve the blob corresponding to the file you are diffing with and inspect it's contents for line endings. Whatever line endings the blob has, you would have to convert to use the same line endings in the blob you are creating.

@laurentkempe
Copy link
Owner

@ricksladkey Could you please try with the beta release of version 2.0.0 on Visual Studio 2013 to see if it fixes your issues! That would be really helpful.Thanks

@laurentkempe laurentkempe added bug and removed bug labels Aug 12, 2014
@ricksladkey
Copy link
Contributor Author

I'll take a look. Thanks!

@laurentkempe
Copy link
Owner

Thanks Rick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants