jamesfredley opened a new pull request, #15708:
URL: https://github.com/apache/grails-core/pull/15708

   ## Problem
   
   `gradlew.bat` (and several other tracked files) show as **permanently 
modified** in `git status`, and `git checkout` / `git reset` cannot clear it. 
Reported on macOS.
   
   ## Root cause
   
   PR #15622 added `.gitattributes` (`* text=auto`, `*.bat text eol=crlf`, and 
`*.sh`/`gradlew`/`KEYS`/`Dockerfile`/`*.properties` `text eol=lf`) but did not 
run `git add --renormalize`. So 11 files that were committed earlier kept 
**CRLF blobs in the index**.
   
   Under `text`, the canonical (index) form must be LF, so a CRLF-stored blob 
permanently conflicts with the attribute: git normalizes the working copy to LF 
and compares it against the CRLF blob, which never matches. The file flips to 
"modified" the moment any tool (IDE Gradle sync, branch switch, build, editor 
save) busts git's lstat cache, and `checkout`/`reset` cannot repair it because 
the wrong bytes live in the committed blob.
   
   A fresh clone looks clean (git trusts the stat cache after checkout), which 
is why it seems intermittent. Windows commonly masks it; Mac/Linux dev flows 
touch the wrapper files constantly and trip it.
   
   ## Fix
   
   `git add --renormalize .` - rewrites the affected index blobs to LF. This is 
a **pure line-ending change**: `git diff --ignore-cr-at-eol` is empty (2019 
insertions / 2019 deletions, every line re-emitted with CR stripped). Working 
trees are unaffected: `*.bat` is still checked out as CRLF via `eol=crlf`, so 
**Windows behavior does not change**. After this commit the previously-broken 
files behave exactly like the `gradlew.bat` copies that were already stored 
correctly as LF (which never went dirty).
   
   ## Renormalized files (11)
   
   - `LICENSE`
   - `gradlew.bat`
   - `grails-encoder/src/main/groovy/org/grails/buffer/StreamByteBuffer.java`
   - 
`grails-encoder/src/main/groovy/org/grails/encoder/impl/URLCodecFactory.groovy`
   - `grails-spring/src/main/groovy/org/grails/spring/BeanConfiguration.java`
   - 
`grails-spring/src/main/groovy/org/grails/spring/DefaultBeanConfiguration.java`
   - 
`grails-spring/src/main/groovy/org/grails/spring/DefaultRuntimeSpringConfiguration.java`
   - 
`grails-test-suite-uber/src/test/groovy/org/grails/web/plugins/support/MyHandlerInterceptor.java`
   - 
`grails-test-suite-uber/src/test/groovy/org/grails/web/plugins/support/MyWebRequestInterceptor.java`
   - 
`grails-test-suite-uber/src/test/groovy/org/grails/web/plugins/support/web-interceptor-wiring-tests.xml`
   - 
`grails-test-suite-web/src/test/groovy/org/grails/web/servlet/BindDataMethodTests.groovy`
   
   ## Verification
   
   - Reproduced the permanent dirtiness on Linux: fresh clone clean -> a tool 
touches the file -> ` M gradlew.bat` -> `git checkout -- gradlew.bat` does 
**not** fix it -> `git add --renormalize` + commit -> clean forever.
   - `git diff --cached --ignore-cr-at-eol` is empty (zero content change).
   
   ## Note on 8.0.x
   
   Targeted at `7.0.x` so it merges forward. `8.0.x` has **4 additional** 
`gradlew.bat` files (`build-logic/`, `grails-gradle/`, 
`grails-profiles/profile/skeleton/`, 
`grails-shell-cli/src/test/resources/gradle-sample/`) stored as CRLF that are 
already LF on `7.0.x`; those will need a separate `git add --renormalize` on 
`8.0.x`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to