add documentation about the 'spurious EOL normalization' bug in GitHub - #452
add documentation about the 'spurious EOL normalization' bug in GitHub#452pchampin wants to merge 3 commits into
Conversation
| ``` | ||
| * text=auto | ||
| ``` |
There was a problem hiding this comment.
Others were advocating
* text=auto eol=lf
are we 100% sure that the eol=lf is superfluous? Or is it wrong to set it this way?
There was a problem hiding this comment.
My understanding is that eol=lf will force the local copies to use LF, including on Windows, which some (crude) editors may not like.
From the GIT documentation
If the eol attribute is unspecified for a file, its line endings in the working directory are determined by the core.autocrlf or core.eol configuration variable (see the definitions of those options in git-config[1]). If text is set but neither of those variables is, the default is eol=crlf on Windows and eol=lf on all other platforms.
So leaving it unspecified seems better.
There was a problem hiding this comment.
And I did explicitly test this on Windows, and it does force all files in my working directory to have LF line endings, which is wrong for Windows. That said, even Notepad can handle such files, so I am not sure what practical impact it has these days. But I advocate for not forcing that (no eol=lf added) as it seems unrelated (you just want to normalize line endings in the repo, what I do with the files should be up to me).
There was a problem hiding this comment.
My understanding is that eol=lf will force the local copies to use LF, including on Windows
Maybe so. Somewhere someone must be able to answer why when those configuration files are not in place, a Mac-based LF user of the GitHub browser interface gets their file(s) normalized to the Windows CRLF.
| + checkout the branch of the PR locally | ||
| + modify the incriminated commit with [`git rebase -i`](https://git-scm.com/docs/git-rebase#_interactive_mode); | ||
| a useful command to change all CRLFs back to LFs is `sed 's/\r$//' -i [filename]` | ||
| + "force-push" the rebased branch with `git push --force` |
There was a problem hiding this comment.
I think a slightly more verbose description of what can/should be done is worth adding for less advanced users...
There was a problem hiding this comment.
That's why I marked this item as for "advanced users" :-)
I didn't have time to turn this into a proper tutorial, and I don't think this should block this page from being added. But +1 to be more explicit about it, eventually.
| * running `git add . --renormalize` | ||
| to ask GIT to remove all mixed EOL in text files already present in the repository. | ||
| (Again, this will *not* change the local copies.) |
There was a problem hiding this comment.
There are possible objections to this, see w3c/vc-wg#16 (comment)
There was a problem hiding this comment.
I'll respond to those objections in that thread, but I don't think this step is actually required, so I added "optionally" in front of this bullet.
Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
bduga
left a comment
There was a problem hiding this comment.
LGTM. A couple of suggested changes, but they are codepoint neutral (no code points added or removed).
| in a PR, and possibly after using the | ||
| [online editor](https://docs.github.com/en/codespaces/the-githubdev-web-based-editor), | ||
| the PR appears to modify *all the lines* of a given file. | ||
| The change in most line is in fact only touching the end-of-line (EOL) character, changing all LFs to CRLFs. |
There was a problem hiding this comment.
| The change in most line is in fact only touching the end-of-line (EOL) character, changing all LFs to CRLFs. | |
| The change in most lines is in fact only touching the end-of-line (EOL) character, changing all LFs to CRLFs. |
| > [!Note] | ||
| > This behaviour is not a "normal" GIT behaviour: | ||
| > to reproduce it, one has to tweak the GIT configuration between the time the file is checked out and the time the file is commited! | ||
| > It seems more likely that it is a GitHUb bug. |
There was a problem hiding this comment.
FWIW, I was able to repro this bug entirely in git by setting autocrlf=false on my Windows client and checking out files from a repo that did not have a .gitattributes file specifying end-of-line behavior.
| * It is possible to ask GIT or github to ignore whitespaces when showing the difference between two versions of a file: | ||
|
|
||
| + in github, by clicking on the cog-wheel button in the 'Files changed' view of the PR, | ||
| and checking 'Hide whitespace' (alternatively: adds the `?w=1` parameter to the URL, |
There was a problem hiding this comment.
| and checking 'Hide whitespace' (alternatively: adds the `?w=1` parameter to the URL, | |
| and checking 'Hide whitespace' (alternatively: add the `?w=1` parameter to the URL, |
| ``` | ||
| * text=auto | ||
| ``` |
There was a problem hiding this comment.
And I did explicitly test this on Windows, and it does force all files in my working directory to have LF line endings, which is wrong for Windows. That said, even Notepad can handle such files, so I am not sure what practical impact it has these days. But I advocate for not forcing that (no eol=lf added) as it seems unrelated (you just want to normalize line endings in the repo, what I do with the files should be up to me).
| [applying suggested changes](https://docs.github.com/en/pull-requests/how-tos/review-pull-requests/incorporating-feedback-in-your-pull-request#applying-suggested-changes) | ||
| in a PR, and possibly after using the | ||
| [online editor](https://docs.github.com/en/codespaces/the-githubdev-web-based-editor), | ||
| the PR appears to modify *all the lines* of a given file. |
There was a problem hiding this comment.
| the PR appears to modify *all the lines* of a given file. | |
| GitHub forces the PR modify *all the lines* of a given file, | |
| "normalizing" the EOL characters to CRLF. | |
| GitHub claims they do this only | |
| when they have detected a mix of EOL characters in the file. | |
| To the best of my knowledge, they have not documented what problem is caused by such | |
| a mix of EOL characters, nor why they are defaulting to | |
| normalize to Windows CRLF, which appears | |
| to be a change from previous default behavior. |
as discussed today during global
@iherman