Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit b201cbf

Browse files
patthoytskasal
authored andcommitted
Push the NATIVE_CRLF Makefile variable to C and added a test for native.
Commit 95f31e9 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 <[email protected]> Signed-off-by: Stepan Kasal <[email protected]>
1 parent 5e37e40 commit b201cbf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,9 @@ ifdef NO_REGEX
14791479
COMPAT_CFLAGS += -Icompat/regex
14801480
COMPAT_OBJS += compat/regex/regex.o
14811481
endif
1482+
ifdef NATIVE_CRLF
1483+
BASIC_CFLAGS += -DNATIVE_CRLF
1484+
endif
14821485

14831486
ifdef USE_NED_ALLOCATOR
14841487
COMPAT_CFLAGS += -Icompat/nedmalloc

t/t0026-eol-config.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '
8080
test -z "$onediff" -a -z "$twodiff"
8181
'
8282

83+
test_expect_success NATIVE_CRLF 'eol native is crlf' '
84+
85+
rm -rf native_eol && mkdir native_eol &&
86+
( cd native_eol &&
87+
printf "*.txt text\n" > .gitattributes
88+
printf "one\r\ntwo\r\nthree\r\n" > filedos.txt
89+
printf "one\ntwo\nthree\n" > fileunix.txt
90+
git init &&
91+
git config core.autocrlf false &&
92+
git config core.eol native &&
93+
git add filedos.txt fileunix.txt &&
94+
git commit -m "first" &&
95+
rm file*.txt &&
96+
git reset --hard HEAD &&
97+
has_cr filedos.txt && has_cr fileunix.txt
98+
)
99+
'
100+
83101
test_done

0 commit comments

Comments
 (0)