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

Pt/native crlf #77

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -1455,6 +1455,9 @@ endif
ifdef CYGWIN_V15_WIN32API
COMPAT_CFLAGS += -DCYGWIN_V15_WIN32API
endif
ifdef NATIVE_CRLF
BASIC_CFLAGS += -DNATIVE_CRLF
endif

ifdef USE_NED_ALLOCATOR
COMPAT_CFLAGS += -Icompat/nedmalloc
Expand Down
32 changes: 32 additions & 0 deletions t/t0026-eol-config.sh
Expand Up @@ -8,6 +8,20 @@ has_cr() {
tr '\015' Q <"$1" | grep Q >/dev/null
}

# core.eol crlf and core.autocrlf input are not permitted.
# this lets us check for the core.eol native being crlf.
set_native_eol_prereq() {
rm -rf eol && mkdir eol &&
( cd eol &&
git init --quiet &&
git config core.autocrlf input &&
git config core.eol native &&
git var core.eol 2> /dev/null
) ||
test_set_prereq NATIVE_EOL_IS_CRLF
}
set_native_eol_prereq

test_expect_success setup '

git config core.autocrlf false &&
Expand Down Expand Up @@ -80,4 +94,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '
test -z "$onediff" -a -z "$twodiff"
'

test_expect_success NATIVE_EOL_IS_CRLF 'eol native is crlf' '

rm -rf native_eol && mkdir native_eol &&
( cd native_eol &&
printf "*.txt text\n" > .gitattributes
printf "one\r\ntwo\r\nthree\r\n" > filedos.txt
printf "one\ntwo\nthree\n" > fileunix.txt
git init &&
git config core.autocrlf false &&
git config core.eol native &&
git add filedos.txt fileunix.txt &&
git commit -m "first" &&
rm file*.txt &&
git reset --hard HEAD &&
has_cr filedos.txt && has_cr fileunix.txt

Choose a reason for hiding this comment

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

Shouldn't these be "! has_cr" assertions on Windows?

Choose a reason for hiding this comment

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

Never mind; I'm still trying to wrap my head around all of this.

)
'

test_done