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

.braids.json written with LF line endings under Windows, causing intermittent warning #77

Open
mattmccutchen opened this issue Feb 18, 2018 · 2 comments

Comments

@mattmccutchen
Copy link
Collaborator

mattmccutchen commented Feb 18, 2018

On Windows, Braid writes .braids.json with LF line endings. Using Git for Windows with the recommended settings (core.autocrlf = true and core.safecrlf = warn), this produces a warning on git add:

warning: LF will be replaced by CRLF in .braids.json.
The file will have its original line endings in your working directory.

This often goes unnoticed because when Braid calls git add, it swallows the warning (arguably poor design). However, depending on how quickly Braid runs, the index entry for .braids.json may be left "racily clean", in which case the next git add command will print the warning again. This appears to be the cause of the intermittent warnings when I run the test suite on Windows.

Arguably git should be enhanced so that "racily clean" entries do not lead to intermittent duplicate safecrlf warnings (edit: thread). But I'd also argue that we should consider fixing the root cause by changing Braid to write the file with CRLF endings, at least if core.autocrlf = true.

We could look to the .gitmodules file for precedent. Interestingly, git submodule add also writes it with LF endings under Git for Windows and shows a warning. I inquired about this on the Git for Windows discussion group.

@tboegi
Copy link

tboegi commented Feb 21, 2018

Using Git for Windows with the recommended settings
(core.autocrlf = true and core.safecrlf = warn)
Out of curiosity: From where did you get this information ?

My recommended handling in Windows (since some years) is to set up a .gitattributes file.

  • text=auto
    *.json text eol=lf

@mattmccutchen
Copy link
Collaborator Author

Out of curiosity: From where did you get this information ?

core.autocrlf = true: "For cross-platfrom development, this is the recommended setting on Windows development workstations" (source). core.safecrlf = warn is just the git default, not a specifically recommended setting, I suppose.

My recommended handling in Windows (since some years) is to set up a .gitattributes file.

Is there a philosophical reason why JSON files should be treated differently from other text files? If not, then while this certainly works as a workaround for the current Braid behavior, it doesn't justify Braid's behavior.

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

No branches or pull requests

2 participants