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

gitattributes: Set batch files to CRLF line endings on checkout #6442

Closed
wants to merge 1 commit into from

Conversation

jay
Copy link
Member

@jay jay commented Jan 13, 2021

If a batch file is run without CRLF line endings (ie LF-only) then
arbitrary behavior may occur. I consider that a bug in Windows, however
the effects can be serious enough (eg unintended code executed) that
we're fixing it in the repo by requiring CRLF line endings for batch
files on checkout.

Prior to this change the checked-out line endings of batch files were
dependent on a user's git preferences. On Windows it is common for git
users to have automatic CRLF conversion enabled (core.autocrlf true),
but those users that don't would run into this behavior.

For example a user has reported running the Visual Studio project
generator batch file (projects/generate.bat) and it looped forever.
Output showed that the Windows OS interpreter was occasionally jumping
to arbitrary points in the batch file and executing commands. This
resulted in unintended files being removed (a removal sequence called)
and looping forever.

Ref: https://serverfault.com/q/429594
Ref: https://stackoverflow.com/q/232651
Ref: https://www.dostips.com/forum/viewtopic.php?t=8988
Ref: https://git-scm.com/docs/gitattributes#_checking_out_and_checking_in
Ref: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf

Bug: #6427
Reported-by: Ganesh Kamath

Closes #xxxx


/cc @bitcrazed @dscho

If a batch file is run without CRLF line endings (ie LF-only) then
arbitrary behavior may occur. I consider that a bug in Windows, however
the effects can be serious enough (eg unintended code executed) that
we're fixing it in the repo by requiring CRLF line endings for batch
files on checkout.

Prior to this change the checked-out line endings of batch files were
dependent on a user's git preferences. On Windows it is common for git
users to have automatic CRLF conversion enabled (core.autocrlf true),
but those users that don't would run into this behavior.

For example a user has reported running the Visual Studio project
generator batch file (projects/generate.bat) and it looped forever.
Output showed that the Windows OS interpreter was occasionally jumping
to arbitrary points in the batch file and executing commands. This
resulted in unintended files being removed (a removal sequence called)
and looping forever.

Ref: https://serverfault.com/q/429594
Ref: https://stackoverflow.com/q/232651
Ref: https://www.dostips.com/forum/viewtopic.php?t=8988
Ref: https://git-scm.com/docs/gitattributes#_checking_out_and_checking_in
Ref: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf

Bug: curl#6427
Reported-by: Ganesh Kamath

Closes #xxxx
@jay jay added the Windows Windows-specific label Jan 13, 2021
Copy link
Contributor

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jay jay closed this in 70c4fad Jan 14, 2021
@jay jay deleted the batch_crlf_always branch January 14, 2021 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

4 participants