[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 27 19:24:23 PDT 2022
aaronpuchert added a comment.
In D124563#3478978 <https://reviews.llvm.org/D124563#3478978>, @aaronpuchert wrote:
> Git will apply the LF -> CRLF transformation when it checks out itself. Git doesn't show the file as modified because after cleaning the file (i.e. applying CRLF -> LF) it's the same as in the index.
One way to look at this is that the two filters //clean// (for checking in) and //smudge// (for checking out) are neither left nor right inverses of each other.
- The composition //clean// ∘ //smudge// not being the identity caused our original problem of files showing up modified with no way to fix it: no checked-out file could reproduce the checked-in file.
- The composition //smudge// ∘ //clean// not being the identity caused the intermittent issue after `arc patch`: the file didn't show up as modified, even though it wasn't what Git would produce on checkout.
The documentation says that //clean// should be <https://www.git-scm.com/docs/gitattributes> a projection <https://en.wikipedia.org/wiki/Projection_(mathematics)>:
> For best results, `clean` should not alter its output further if it is run twice ("clean→clean" should be equivalent to "clean")
We should also have //clean// ∘ //smudge// ∘ //clean// = //clean//, and that's what `git add --renormalize` uses: by checking in cleaned files we're in the subset of files on which //clean// ∘ //smudge// is the identity. In fact in our case //clean// should even be the equalizer <https://en.wikipedia.org/wiki/Equaliser_(mathematics)> of //smudge// ∘ //clean// and the identity on checked-in files, that is be able to produce every file that survives the round-trip.
In case you needed an advertisement for category theory <https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/>. ;)
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits