From 0a93510b60338349d7a38f4fd47131e76d101d41 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Thu, 27 Aug 2026 16:51:55 +0200 Subject: [PATCH 1/3] add documentation about the 'spurious EOL normalization' bug in GitHub --- github/index.md | 3 ++ github/spurious_eol.md | 69 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 github/spurious_eol.md diff --git a/github/index.md b/github/index.md index 8e87064e..fd5c745e 100644 --- a/github/index.md +++ b/github/index.md @@ -45,3 +45,6 @@ Repositories under the W3C organization may represent the work of Working Groups [Backup of GitHub organizations](backup.md) : How W3C keeps a backup of the different GitHub organizations. + +[The "spurious EOL normalization" bug](spurious_eol.md) +: What to do when a PR suddenly changes all lines in a file? diff --git a/github/spurious_eol.md b/github/spurious_eol.md new file mode 100644 index 00000000..efcddaec --- /dev/null +++ b/github/spurious_eol.md @@ -0,0 +1,69 @@ +GIT -- +title: The "spurious EOL normalization" bug +toc: false +--- + + +# Description of the bug + +After +[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. +The change in most line is in fact only touching the end-of-line (EOL) character, changing all LFs to CRLFs. + +## What causes the bug + +It seems that the bug appears when the following conditions are met: + +* the file contains a mix of CRLF and LF, and +* changes are commited to the file by + [applying suggested changes](https://docs.github.com/en/pull-requests/how-tos/review-pull-requests/incorporating-feedback-in-your-pull-request#applying-suggested-changes) + or (TBC) using the + [online editor](https://docs.github.com/en/codespaces/the-githubdev-web-based-editor). + +> [!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. + + +# Dealing with it + +* 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, + [example](https://github.com/pchampin/test_eol_bug/pull/2/changes?w=1)) + + + on the command line, using the `--ignore-all-space` option of `git diff` + +* Advanced users may "fix" the PR by + + + 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` + + This will retain the individual commits with their authors and messages. + +# Preventing it from happening again + +A workaround consists in: + +* adding a + [`.gitattributes`](https://git-scm.com/docs/gitattributes) + file in the root folder of the repository, containing the following line: + ``` + * text=auto + ``` + + This instructs GIT to guess which files are text files; + any new file deemed to be text will be kept *in the repository* + with EOLs normalized to LF, + regardless of the EOLs in the local copies. + +* 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.) From b49055bfae2085aa543124b33e50ccf76bf4201a Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Fri, 28 Aug 2026 15:14:04 +0200 Subject: [PATCH 2/3] Update github/spurious_eol.md Co-authored-by: Ted Thibodeau Jr --- github/spurious_eol.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/github/spurious_eol.md b/github/spurious_eol.md index efcddaec..48eee047 100644 --- a/github/spurious_eol.md +++ b/github/spurious_eol.md @@ -39,6 +39,8 @@ It seems that the bug appears when the following conditions are met: + on the command line, using the `--ignore-all-space` option of `git diff` +> [!Note] +> Note that this does not *fix* anything; it only changes what is displayed as "changed lines". Further, it conceals changes in indentation which may increase or decrease the number of space characters used for indents, as well as changing indent characters between tabs and spaces. These remain to be manually fixed after resolving the EOL issue. * Advanced users may "fix" the PR by + checkout the branch of the PR locally From 92399cd92bb210d155e58e0ca91a2d6ec2cefd6d Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Champin Date: Fri, 28 Aug 2026 15:25:08 +0200 Subject: [PATCH 3/3] Update spurious_eol.md --- github/spurious_eol.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/github/spurious_eol.md b/github/spurious_eol.md index 48eee047..821c93ca 100644 --- a/github/spurious_eol.md +++ b/github/spurious_eol.md @@ -39,8 +39,9 @@ It seems that the bug appears when the following conditions are met: + on the command line, using the `--ignore-all-space` option of `git diff` -> [!Note] -> Note that this does not *fix* anything; it only changes what is displayed as "changed lines". Further, it conceals changes in indentation which may increase or decrease the number of space characters used for indents, as well as changing indent characters between tabs and spaces. These remain to be manually fixed after resolving the EOL issue. + > [!Note] + > Note that this does not *fix* anything; it only changes what is displayed as "changed lines". Further, it conceals changes in indentation which may increase or decrease the number of space characters used for indents, as well as changing indent characters between tabs and spaces. These remain to be manually fixed after resolving the EOL issue. + * Advanced users may "fix" the PR by + checkout the branch of the PR locally @@ -66,6 +67,6 @@ A workaround consists in: with EOLs normalized to LF, regardless of the EOLs in the local copies. -* running `git add . --renormalize` +* optionally running `git add . --renormalize` followed by `git commit -m "normalize all EOL"` to ask GIT to remove all mixed EOL in text files already present in the repository. (Again, this will *not* change the local copies.)