[PATCH] D124563: Drop '* text=auto' from .gitattributes and normalize

Di Mo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 18:42:55 PDT 2022


modimo added a comment.

In D124563#3478978 <https://reviews.llvm.org/D124563#3478978>, @aaronpuchert wrote:

> In D124563#3478968 <https://reviews.llvm.org/D124563#3478968>, @modimo wrote:
>
>> I used `arc patch` and also saw the same thing.
>
> The patch does actually change the files to LF endings. So just applying the patch with non-Git tools will make LF endings, but 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.

To confirm in main:

  ~/llvm-project2# git ls-files --eol clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  i/lf    w/crlf  attr/text eol=crlf      clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp

`i/lf` indicates in the index it's stored as LF but transformed to `w/crlf` CRLF in the working directory.

After running `arc patch` though:

  ~/llvm-project# llvm-arc patch D124563
  ~/llvm-project# git ls-files --eol clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  i/lf    w/lf    attr/text eol=crlf      clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp

So confirmed it was an `arc patch` diff application. EOL is... tricky.

> Sorry for all the noise, I was just annoyed about this empty `test` directory and thought we just need to move that file... well, it was a bit of an adventure. Thanks for helping out here.

It happens, properly fixing the original diff to make it actually do something was definitely the right choice. If anything Git should warn loudly that the index needs to be refreshed if `.gitattributes` is modified or added.

Happy to help, I learned quite a lot about git internals digging into this :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124563/new/

https://reviews.llvm.org/D124563



More information about the cfe-commits mailing list