Makefile: propagate NATIVE_CRLF to C
Commit 95f31e9a (convert: The native line-ending is \r\n on MinGW, 2010-09-04) correctly points out that the NATIVE_CRLF setting is incorrectly set on Mingw git. However, the Makefile variable is not propagated to the C preprocessor and results in no change. This patch pushes the definition to the C code and adds a test to validate that when core.eol as native is crlf, we actually normalize text files to this line ending convention when core.autocrlf is false. Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net> Signed-off-by: Stepan Kasal <kasal@ucw.cz> Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pat Thoyts committed
Aug 30, 2014 at 23:38 UTC
5491e9e29eef60bd6337de81e9283e67941618e5
2 files changed
+23
Makefile
+3
@@ -1474,6 +1474,9 @@ ifdef NO_REGEX
1474
COMPAT_CFLAGS += -Icompat/regex
1475
COMPAT_OBJS += compat/regex/regex.o
1476
endif
1477
+ifdef NATIVE_CRLF
1478
+ BASIC_CFLAGS += -DNATIVE_CRLF
1479
+endif
1480
1481
ifdef USE_NED_ALLOCATOR
1482
COMPAT_CFLAGS += -Icompat/nedmalloc
t/t0026-eol-config.sh
+20
@@ -80,4 +80,24 @@ test_expect_success 'autocrlf=true overrides unset eol' '
80
test -z "$onediff" && test -z "$twodiff"
81
'
82
83
+test_expect_success NATIVE_CRLF 'eol native is crlf' '
84
+
85
+ rm -rf native_eol && mkdir native_eol &&
86
+ (
87
+ cd native_eol &&
88
+ printf "*.txt text\n" >.gitattributes &&
89
+ printf "one\r\ntwo\r\nthree\r\n" >filedos.txt &&
90
+ printf "one\ntwo\nthree\n" >fileunix.txt &&
91
+ git init &&
92
+ git config core.autocrlf false &&
93
+ git config core.eol native &&
94
+ git add filedos.txt fileunix.txt &&
95
+ git commit -m "first" &&
96
+ rm file*.txt &&
97
+ git reset --hard HEAD &&
98
+ has_cr filedos.txt &&
99
+ has_cr fileunix.txt
100
+ )
101
+'
102
+
103
test_done