Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pt/native crlf (with updates) #88

Closed
wants to merge 2 commits into from

5 participants

Brice Lambson BuildHive dscho Pat Thoyts Matthieu Vachon
Brice Lambson

This is another iteration on top of pull request #77 in an attempt to get issue #57 fixed.

Pat Thoyts patthoyts Push the NATIVE_CRLF Makefile variable to C and added a test for native.
The previous patch 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>
8727c0c
t/t6038-merge-text-auto.sh
@@ -97,9 +97,9 @@ test_expect_success 'Merge addition of text=auto' '
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
q_to_cr <<-\EOF >expected &&
<<<<<<<
- first line
- same line
- =======
+ first lineQ
+ same lineQ
+ =======Q
first lineQ
same lineQ
>>>>>>>

These changes don't feel right to me. It seems like the conflict file should preserve the line endings instead of normalize them all to crlf. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Brice Lambson

Also, should these tests handle different native line endings? If so, what is the best way to make them conditional?

BuildHive

MSysGit - the development behind Git for Windows » git #116 FAILURE
Looks like there's a problem with this pull request
(what's this?)

Brice Lambson

Hmm... @buildhive doesn't appear to have built the updated version of git before running the tests. I'm not sure what I'm doing wrong here. Is there any documentation on submitting pull request to this project?

dscho
Owner

@bricelam actually, BuildHive builds on Linux. And it did it correctly: when I check out your crlf branch here, on Linux, and run the tests, I run into exactly the same problem:

*** t0026-eol-config.sh ***
ok 1 - setup
ok 2 - eol=lf puts LFs in normalized file
ok 3 - eol=crlf puts CRLFs in normalized file
ok 4 - autocrlf=true overrides eol=lf
ok 5 - autocrlf=true overrides unset eol
not ok 6 - eol native is crlf
#   
#   
#       rm -rf native_eol && mkdir native_eol &&
#       ( cd native_eol &&
#       printf "*.txt text
#   " > .gitattributes
#       printf "one
#   two
#   three
#   " > filedos.txt
#       printf "one
#   two
#   three
#   " > 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
#       )
#   
# failed 1 among 6 test(s)
1..6
make[2]: *** [t0026-eol-config.sh] Error 1

I think the reason is that your patch turns a failing test into a platform-specific (and therefore again failing) test. Remember: the Git code base is -- theoretically -- shared between all the platforms. It just does not make sense to maintain possibly-incompatible versions for the different platforms. The fact that Git for Windows has to maintain a couple of patches because they have not been accepted upstream in their current form is beside the point: the intention is actually to converge one day, when Git for Windows has enough active contributors that we can address all the nitpicks of upstream Git to get the patches into mainline.

Therefore we cannot change a failing test in such a way that it passes on Windows and fails everywhere else: most likely it means that the test is actually not precise enough. It probably assumes a certain native line ending convention, in which case it has to be either marked as such so it can be skipped if the native line ending is different than assumed or it has to be fixed not to assume a certain native line ending.

Also: you can force-push into the crlf branch. This will update this pull request, there is no need to make a new one.

Please let this not discourage you from working on this issue! I am positively surprised by your contribution. And please do not let the silence from my side from Monday through the beginning of next month discourage you, either, I will be offline, hoping all the while that other developers will step in and bring this pull request to a beautiful resolution.

Thanks!

dscho
Owner

On Thu, 15 Aug 2013, Brice Lambson wrote:

Also, should these tests be handle different native line endings? If so, what is the best way to make them conditional?

There are some conditions you can specify, just git grep for NATIVE_EOL_IS_CRLF. This will show you how to define such conditions, and how to make them a pre-requisite for running a specific test (and skipping said test if the pre-requisite is not met).

Brice Lambson

@dscho I started to suspect today that it might be building on Linux today, thanks for confirming. I'm also delighted to hear that the goal is to converge into a single git codebase. I will definitely change the tests to be more platform agnostic then. :) Thank you for all your help and patience. Hopefully I can get another iteration out soon.

Pat Thoyts
Owner

This seems good to me - building this branch on my machine and running the tests has no failures other than t9903-bash-prompt 12-13 which fail anyway on the msys build. The only problem I see is that the commit message should explain as clearly as possibly why the change to append_cr is used and explain the change to 'Detect CRLF/LF conflict after setting text=auto'. Ultimately we would expect to forward these patches upstream and we need to conform to git's usual commit standards and be verbose in explaining the thinking behind changes. Particularly as crlf/lf issues are generally a bit tricky.

Brice Lambson

Thanks, Pat. I will update the tests to pass on both Linux and Windows, update my commit message per Git's guidelines, and update the pull request.

Brice Lambson bricelam MinGW: Update tests to handle a native eol of crlf
Some of the tests were written with the assumption that the native eol would always be lf. After defining NATIVE_CRLF on MinGW, these tests began failing. This change will update the tests to also handle a native eol of crlf.

Signed-off-by: Brice Lambson <bricelam@live.com>
635d6a0
Pat Thoyts
Owner

Merged by rebasing onto the 1.8.4 master.

Pat Thoyts patthoyts closed this
Pat Thoyts patthoyts referenced this pull request
Closed

Pt/native crlf #77

Matthieu Vachon

Tested with latest release, (msys) git 1.8.4 released few hours ago and it works like a charm. I think issue #57 can be close now that this PR has been merged into master.

Thanks @bricelam for the work on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 15, 2013
  1. Pat Thoyts Brice Lambson

    Push the NATIVE_CRLF Makefile variable to C and added a test for native.

    patthoyts authored bricelam committed
    The previous patch 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>
Commits on Aug 23, 2013
  1. Brice Lambson

    MinGW: Update tests to handle a native eol of crlf

    bricelam authored
    Some of the tests were written with the assumption that the native eol would always be lf. After defining NATIVE_CRLF on MinGW, these tests began failing. This change will update the tests to also handle a native eol of crlf.
    
    Signed-off-by: Brice Lambson <bricelam@live.com>
This page is out of date. Refresh to see the latest.
3  Makefile
View
@@ -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
18 t/t0026-eol-config.sh
View
@@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '
test -z "$onediff" -a -z "$twodiff"
'
+test_expect_success NATIVE_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
+ )
+'
+
test_done
54 t/t6038-merge-text-auto.sh
View
@@ -72,6 +72,10 @@ test_expect_success 'Merge after setting text=auto' '
same line
EOF
+ if test_have_prereq NATIVE_CRLF; then
+ append_cr <expected >expected.temp &&
+ mv expected.temp expected
+ fi &&
git config merge.renormalize true &&
git rm -fr . &&
rm -f .gitattributes &&
@@ -86,6 +90,10 @@ test_expect_success 'Merge addition of text=auto' '
same line
EOF
+ if test_have_prereq NATIVE_CRLF; then
+ append_cr <expected >expected.temp &&
+ mv expected.temp expected
+ fi &&
git config merge.renormalize true &&
git rm -fr . &&
rm -f .gitattributes &&
@@ -95,16 +103,19 @@ test_expect_success 'Merge addition of text=auto' '
'
test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
- q_to_cr <<-\EOF >expected &&
- <<<<<<<
- first line
- same line
- =======
- first lineQ
- same lineQ
- >>>>>>>
- EOF
-
+ echo "<<<<<<<" >expected &&
+ if test_have_prereq NATIVE_CRLF; then
+ echo first line | append_cr >>expected &&
+ echo same line | append_cr >>expected &&
+ echo ======= | append_cr >>expected
+ else
+ echo first line >>expected &&
+ echo same line >>expected &&
+ echo ======= >>expected
+ fi &&
+ echo first line | append_cr >>expected &&
+ echo same line | append_cr >>expected &&
+ echo ">>>>>>>" >>expected &&
git config merge.renormalize false &&
rm -f .gitattributes &&
git reset --hard a &&
@@ -114,16 +125,19 @@ test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
'
test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
- q_to_cr <<-\EOF >expected &&
- <<<<<<<
- first lineQ
- same lineQ
- =======
- first line
- same line
- >>>>>>>
- EOF
-
+ echo "<<<<<<<" >expected &&
+ echo first line | append_cr >>expected &&
+ echo same line | append_cr >>expected &&
+ if test_have_prereq NATIVE_CRLF; then
+ echo ======= | append_cr >>expected &&
+ echo first line | append_cr >>expected &&
+ echo same line | append_cr >>expected
+ else
+ echo ======= >>expected &&
+ echo first line >>expected &&
+ echo same line >>expected
+ fi &&
+ echo ">>>>>>>" >>expected &&
git config merge.renormalize false &&
rm -f .gitattributes &&
git reset --hard b &&
1  t/test-lib.sh
View
@@ -679,6 +679,7 @@ case $(uname -s) in
# exec does not inherit the PID
test_set_prereq MINGW
test_set_prereq NOT_CYGWIN
+ test_set_prereq NATIVE_CRLF
test_set_prereq SED_STRIPS_CR
;;
*CYGWIN*)
Something went wrong with that request. Please try again.