Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the sh scripts all have only LFs (not CRLFs) #32

Closed
xparq opened this issue Feb 2, 2023 · 6 comments
Closed

Make sure the sh scripts all have only LFs (not CRLFs) #32

xparq opened this issue Feb 2, 2023 · 6 comments

Comments

@xparq
Copy link
Owner

xparq commented Feb 2, 2023

(Originally: xparq/Args#33)

The .gitattributes settings supposedly already ensure that it's that way in the repo.
However, I still had core.autocrlf enabled locally, and either because of that or it was just never changed, (some of?) the scripts still had CRLF (in the work tree at least).

I recently dos2unixed them all, and also did a git add --renormalize (which didn't change anything then, but suppressed Git's really inexplicable "...will change to CRLF" warning); let's see what happens next time I check something out and feed it e.g. to WSL's bash...

@xparq xparq changed the title Scripts: Make sure the sh scripts all have only LFs (not CRLFs) Make sure the sh scripts all have only LFs (not CRLFs) Feb 2, 2023
xparq added a commit that referenced this issue Feb 2, 2023
@xparq
Copy link
Owner Author

xparq commented Feb 2, 2023

OK, since run_cases has no extension, .gitattributes doesn't work this way, it must be inverted to do LF by default (for *)!
Then only set .cmd to CRLF, and leave the rest as auto!

@xparq
Copy link
Owner Author

xparq commented Feb 2, 2023

No, 09fca6a did nothing about run_cases, it still kept? converted? it to have CRLFs!... :-/ (As checked in a newly cloned repo.)

@xparq
Copy link
Owner Author

xparq commented Feb 2, 2023

Wow, those idiotic "backwards" warnings about the impending LF->CRLF conversions DESPITE and AFTER setting autocrlf to false and specifically declaring the .sh files as eol=LF in .gitattributes, those are the ones that are "CRLF the most"! :D

It seems that .gitattributes did the exact opposite of what I assumed it would! :-o

git ls-files --eol

i/crlf  w/crlf  attr/                 	.gitattributes
i/lf    w/lf    attr/                 	.gitignore
i/lf    w/lf    attr/                 	README.txt
i/lf    w/crlf  attr/text             	misc/loc.sh
i/lf    w/crlf  attr/text             	test/ .cfg
i/lf    w/lf    attr/                 	test/Args.hpp
i/lf    w/lf    attr/                 	test/Makefile
i/lf    w/lf    attr/                 	test/README - SH compound commands.case/CASE
i/none  w/none  attr/                 	test/README - SH compound commands.case/Hi from the test case dir!
i/lf    w/lf    attr/                 	test/README - SH.case/case
i/lf    w/lf    attr/                 	test/README - SH.case/expect
i/lf    w/lf    attr/                 	test/README - interleaved EXPECTs control.case/case
i/lf    w/lf    attr/                 	test/README - interleaved EXPECTs control.case/expect
i/lf    w/lf    attr/                 	test/README - interleaved EXPECTs.case/case
i/lf    w/lf    attr/                 	test/README.case/case
i/lf    w/lf    attr/                 	test/README.txt
i/lf    w/lf    attr/                 	test/TC dir with no suffix/CASE
i/lf    w/lf    attr/                 	test/_engine/asset/TC-Makefile.gnumake
i/lf    w/lf    attr/                 	test/_engine/asset/TC-Makefile.nmake
i/lf    w/crlf  attr/text             	test/_engine/build.sh
i/lf    w/lf    attr/                 	test/_engine/download_file.ps1
i/lf    w/crlf  attr/text             	test/_engine/functions.sh
i/lf    w/crlf  attr/text             	test/_engine/init_once.sh
i/lf    w/crlf  attr/text             	test/_engine/init_per_case.sh
i/lf    w/crlf  attr/text             	test/_engine/run_case
i/lf    w/lf    attr/                 	test/_these are expected to fail, test them separately!/except.case
i/lf    w/lf    attr/                 	test/_todo/exename.case - fails today, was ok yesterday/CASE
i/lf    w/lf    attr/                 	test/_todo/exename.case - fails today, was ok yesterday/exename.cpp
i/lf    w/crlf  attr/text             	test/_todo/exename.case - fails today, was ok yesterday/t.sh
i/lf    w/lf    attr/                 	test/_todo/exename.case - gcc why different when run from script/CASE
i/lf    w/lf    attr/                 	test/_todo/exename.case - gcc why different when run from script/exename.cpp
i/lf    w/lf    attr/                 	test/expect file.case/CASE
i/lf    w/lf    attr/                 	test/expect file.case/EXPECT
i/lf    w/lf    attr/                 	test/expect unquoted.case
i/lf    w/lf    attr/                 	test/expect-test 1 (one-line).case
i/lf    w/lf    attr/                 	test/general.case
i/-text w/-text attr/                 	test/issue 10.case/case
i/lf    w/lf    attr/                 	test/issue 10.case/issue 10.cpp
i/lf    w/lf    attr/                 	test/long_basic.case
i/lf    w/lf    attr/                 	test/long_colon.case
i/lf    w/lf    attr/                 	test/long_multi.case
i/-text w/-text attr/                 	test/oneliner-example.case
i/lf    w/crlf  attr/text             	test/run_cases
i/lf    w/crlf  attr/text             	test/run_cases.cmd
i/lf    w/lf    attr/                 	test/short_single_no_param.case
i/lf    w/lf    attr/                 	test/subset subdir/subtree case 1.case
i/lf    w/lf    attr/                 	test/subset subdir/subtree case with build.case/CASE
i/lf    w/lf    attr/                 	test/subset subdir/subtree case with build.case/subtree case with build.cpp
i/lf    w/lf    attr/                 	test/test-demo.cpp

@xparq
Copy link
Owner Author

xparq commented Feb 2, 2023

And https://git-scm.com/docs/gitattributes... It clearly says:

eol
...
Set to string value "lf"
This setting forces Git to normalize line endings to LF on checkin and prevents conversion to CRLF when the file is checked out.

xparq added a commit that referenced this issue Feb 2, 2023
xparq added a commit that referenced this issue Feb 2, 2023
@xparq
Copy link
Owner Author

xparq commented Feb 2, 2023

OK, fukit, I gave in, and just set lf the default (-> also e.g. https://stackoverflow.com/a/42136008/1479945):

# So, perhaps "all LF by default" would finally convince it to forget about CRLFs:
* text=auto eol=lf

With the exceptions:

*.cmd	eol=CRLF
*.ps1	eol=CRLF

This seems to work now, finally.

@xparq xparq closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant