]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
gitattributes: Set batch files to CRLF line endings on checkout
authorJay Satiro <raysatiro@yahoo.com>
Wed, 13 Jan 2021 07:03:57 +0000 (02:03 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Thu, 14 Jan 2021 20:59:56 +0000 (15:59 -0500)
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: https://github.com/curl/curl/discussions/6427
Reported-by: Ganesh Kamath
Closes https://github.com/curl/curl/pull/6442

.gitattributes

index cd3fde9545c4253d007a92de65d965d4bc8e4865..691da62282dfa8d174ed9d6c4692f1f10572aef3 100644 (file)
@@ -6,3 +6,9 @@ configure.ac eol=lf
 *.am eol=lf
 *.sh eol=lf
 *.[ch] whitespace=tab-in-indent
+
+# Batch files (bat,btm,cmd) must be run with CRLF line endings.
+# Refer to https://github.com/curl/curl/pull/6442
+*.bat text eol=crlf
+*.btm text eol=crlf
+*.cmd text eol=crlf