Bug 578519 - [win32] Enforce CRLF in .bat scripts
If someone (such as me) has git configured with 'core.autocrlf' other
then 'true', then SWT's .bat files will have LF file endings.
There is a bug with .bat scripts saved with LF line endings, where
it incorrectly finds labels for CALL, if the label is on 512 bytes
boundary from CALL itself.
The problem has been observed many times already:
https://www.dostips.com/forum/viewtopic.php?t=8988
https://issues.jenkins-ci.org/browse/JENKINS-9528
https://stackoverflow.com/questions/232651
I also hit this problem while working on the patch for this Bug.
For example, the following batch script unexpectedly prints "Ending" on
the first line, when saved with LF line endings:
--------
@ECHO OFF
CALL :Test
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 5678901234567890123456789012345678901234567890
REM 56789012345678901234567890123456789012345678
CALL :Test
ECHO Ending
GOTO :EOF
:Test
ECHO Function
GOTO :EOF
--------
The solution is to force .bat files to have CRLF line endings.
Change-Id: I9beb12a417ea843f16bd239c464a1636e27f4d9e
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/190331
Tested-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..69b47b5
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.bat text eol=crlf