{"thread":{"id":"37372","subject":"[PATCH] Push the NATIVE_CRLF Makefile variable to C and added a test for native.","startedAt":"2014-08-18T19:31:20Z","lastAt":"2014-08-19T18:19:43Z","messageCount":3,"participants":["Torsten Bögershausen","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"247857","messageId":"53F25488.8000103@web.de","threadId":"37372","inReplyTo":null,"subject":"[PATCH] Push the NATIVE_CRLF Makefile variable to C and added a test for native.","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-08-18T19:31:20Z","receivedAt":"2014-08-18T19:31:20Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"Commit 95f31e9a correctly points out that the NATIVE_CRLF setting is\nincorrectly set on Mingw git. However, the Makefile variable is not\npropagated to the C preprocessor and results in no change. This patch\npushes the definition to the C code and adds a test to validate that\nwhen core.eol as native is crlf, we actually normalize text files to this\nline ending convention when core.autocrlf is false.\n\nSigned-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\nSigned-off-by: Stepan Kasal <kasal@ucw.cz>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n\n(This is from MINGW, and some part of my brain thougth that this was send\nupstream, but it wasn't. Only 95f31e9a is in git.git)\n\n Makefile              |  3 +++\n t/t0026-eol-config.sh | 18 ++++++++++++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 63a210d..13311d2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1481,6 +1481,9 @@ ifdef NO_REGEX\n \tCOMPAT_CFLAGS += -Icompat/regex\n \tCOMPAT_OBJS += compat/regex/regex.o\n endif\n+ifdef NATIVE_CRLF\n+\tBASIC_CFLAGS += -DNATIVE_CRLF\n+endif\n \n ifdef USE_NED_ALLOCATOR\n        COMPAT_CFLAGS += -Icompat/nedmalloc\ndiff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh\nindex 4807b0f..43a580a 100755\n--- a/t/t0026-eol-config.sh\n+++ b/t/t0026-eol-config.sh\n@@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '\n \ttest -z \"$onediff\" && test -z \"$twodiff\"\n '\n \n+test_expect_success NATIVE_CRLF 'eol native is crlf' '\n+\n+\trm -rf native_eol && mkdir native_eol &&\n+\t( cd native_eol &&\n+\tprintf \"*.txt text\\n\" > .gitattributes\n+\tprintf \"one\\r\\ntwo\\r\\nthree\\r\\n\" > filedos.txt\n+\tprintf \"one\\ntwo\\nthree\\n\" > fileunix.txt\n+\tgit init &&\n+\tgit config core.autocrlf false &&\n+\tgit config core.eol native &&\n+\tgit add filedos.txt fileunix.txt &&\n+\tgit commit -m \"first\" &&\n+\trm file*.txt &&\n+\tgit reset --hard HEAD &&\n+\thas_cr filedos.txt && has_cr fileunix.txt\n+\t)\n+'\n+\n test_done\n-- \n2.1.0.rc2.210.g636bceb\n"},{"id":"247889","messageId":"CAPig+cT4PidGPBE3aQKWme+eXcY3a1LEQNt+5eWQNzZ1jCqz6A@mail.gmail.com","threadId":"37372","inReplyTo":"53F25488.8000103@web.de","subject":"Re: [PATCH] Push the NATIVE_CRLF Makefile variable to C and added a test for native.","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-08-19T04:44:58Z","receivedAt":"2014-08-19T04:44:58Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Aug 18, 2014 at 3:31 PM, Torsten Bögershausen <tboegi@web.de> wrote:\n> Commit 95f31e9a correctly points out that the NATIVE_CRLF setting is\n> incorrectly set on Mingw git. However, the Makefile variable is not\n> propagated to the C preprocessor and results in no change. This patch\n> pushes the definition to the C code and adds a test to validate that\n> when core.eol as native is crlf, we actually normalize text files to this\n> line ending convention when core.autocrlf is false.\n>\n> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\n> Signed-off-by: Stepan Kasal <kasal@ucw.cz>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>\n> (This is from MINGW, and some part of my brain thougth that this was send\n> upstream, but it wasn't. Only 95f31e9a is in git.git)\n>\n>  Makefile              |  3 +++\n>  t/t0026-eol-config.sh | 18 ++++++++++++++++++\n>  2 files changed, 21 insertions(+)\n>\n> diff --git a/Makefile b/Makefile\n> index 63a210d..13311d2 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1481,6 +1481,9 @@ ifdef NO_REGEX\n>         COMPAT_CFLAGS += -Icompat/regex\n>         COMPAT_OBJS += compat/regex/regex.o\n>  endif\n> +ifdef NATIVE_CRLF\n> +       BASIC_CFLAGS += -DNATIVE_CRLF\n> +endif\n>\n>  ifdef USE_NED_ALLOCATOR\n>         COMPAT_CFLAGS += -Icompat/nedmalloc\n> diff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh\n> index 4807b0f..43a580a 100755\n> --- a/t/t0026-eol-config.sh\n> +++ b/t/t0026-eol-config.sh\n> @@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '\n>         test -z \"$onediff\" && test -z \"$twodiff\"\n>  '\n>\n> +test_expect_success NATIVE_CRLF 'eol native is crlf' '\n> +\n> +       rm -rf native_eol && mkdir native_eol &&\n> +       ( cd native_eol &&\n> +       printf \"*.txt text\\n\" > .gitattributes\n> +       printf \"one\\r\\ntwo\\r\\nthree\\r\\n\" > filedos.txt\n> +       printf \"one\\ntwo\\nthree\\n\" > fileunix.txt\n\nBroken &&-chain (3 lines).\n\n> +       git init &&\n> +       git config core.autocrlf false &&\n> +       git config core.eol native &&\n> +       git add filedos.txt fileunix.txt &&\n> +       git commit -m \"first\" &&\n> +       rm file*.txt &&\n> +       git reset --hard HEAD &&\n> +       has_cr filedos.txt && has_cr fileunix.txt\n> +       )\n> +'\n> +\n>  test_done\n> --\n> 2.1.0.rc2.210.g636bceb\n"},{"id":"247956","messageId":"xmqqsiksuytc.fsf@gitster.dls.corp.google.com","threadId":"37372","inReplyTo":"53F25488.8000103@web.de","subject":"Re: [PATCH] Push the NATIVE_CRLF Makefile variable to C and added a test for native.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-08-19T18:19:43Z","receivedAt":"2014-08-19T18:19:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> Commit 95f31e9a correctly points out that the NATIVE_CRLF setting is\n> incorrectly set on Mingw git. However, the Makefile variable is not\n> propagated to the C preprocessor and results in no change. This patch\n> pushes the definition to the C code and adds a test to validate that\n> when core.eol as native is crlf, we actually normalize text files to this\n> line ending convention when core.autocrlf is false.\n>\n> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\n> Signed-off-by: Stepan Kasal <kasal@ucw.cz>\n> Signed-off-by: Torsten Bögershausen <tboegi@web.de>\n> ---\n>\n> (This is from MINGW, and some part of my brain thougth that this was send\n> upstream, but it wasn't. Only 95f31e9a is in git.git)\n>\n>  Makefile              |  3 +++\n>  t/t0026-eol-config.sh | 18 ++++++++++++++++++\n>  2 files changed, 21 insertions(+)\n>\n> diff --git a/Makefile b/Makefile\n> index 63a210d..13311d2 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1481,6 +1481,9 @@ ifdef NO_REGEX\n>  \tCOMPAT_CFLAGS += -Icompat/regex\n>  \tCOMPAT_OBJS += compat/regex/regex.o\n>  endif\n> +ifdef NATIVE_CRLF\n> +\tBASIC_CFLAGS += -DNATIVE_CRLF\n> +endif\n>  \n>  ifdef USE_NED_ALLOCATOR\n>         COMPAT_CFLAGS += -Icompat/nedmalloc\n> diff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh\n> index 4807b0f..43a580a 100755\n> --- a/t/t0026-eol-config.sh\n> +++ b/t/t0026-eol-config.sh\n> @@ -80,4 +80,22 @@ test_expect_success 'autocrlf=true overrides unset eol' '\n>  \ttest -z \"$onediff\" && test -z \"$twodiff\"\n>  '\n>  \n> +test_expect_success NATIVE_CRLF 'eol native is crlf' '\n\nWho defines this test prerequisite?\n\n> +\n> +\trm -rf native_eol && mkdir native_eol &&\n> +\t( cd native_eol &&\n> +\tprintf \"*.txt text\\n\" > .gitattributes\n> +\tprintf \"one\\r\\ntwo\\r\\nthree\\r\\n\" > filedos.txt\n> +\tprintf \"one\\ntwo\\nthree\\n\" > fileunix.txt\n\nStyle and nits:\n\n - No SP between a redirection operator and its target.\n - Broken && chain.\n - Not indented.\n\ni.e.\n\n\trm -rf native_eol &&\n        mkdir native_eol &&\n        (\n\t\tcd native_eol &&\n                printf ... >.gitattributes &&\n\t\t...\n                has_cr filedos.txt &&\n                has_cr fileunix.txt\n\t)\n\n> +\tgit init &&\n> +\tgit config core.autocrlf false &&\n> +\tgit config core.eol native &&\n> +\tgit add filedos.txt fileunix.txt &&\n> +\tgit commit -m \"first\" &&\n> +\trm file*.txt &&\n> +\tgit reset --hard HEAD &&\n> +\thas_cr filedos.txt && has_cr fileunix.txt\n> +\t)\n> +'\n> +\n>  test_done\n"}]}