{"thread":{"id":"39198","subject":"[PATCH v3] blame: CRLF in the working tree and LF in the repo","startedAt":"2015-05-01T11:02:47Z","lastAt":"2015-05-01T11:02:47Z","messageCount":1,"participants":["Torsten Bögershausen"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"260311","messageId":"55435D57.8060906@web.de","threadId":"39198","inReplyTo":null,"subject":"[PATCH v3] blame: CRLF in the working tree and LF in the repo","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2015-05-01T11:02:47Z","receivedAt":"2015-05-01T11:02:47Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"A typical setup under Windows:\ncore.eol is CRLF and a file is marked as \"text\" in .gitattributes,\nor core.autocrlf is true\n\nAfter 4d4813a5 \"git blame\" no longer works as expected,\nevery line is annotated as \"Not Committed Yet\",\neven though the working directory is clean.\n\ncommit 4d4813a5 removed the conversion in blame.c for all files,\nwith or without CRLF in the repo.\n\nHaving files with CRLF in the repo and core.autocrlf=input is a temporary\nsituation, the files should be normalized in the repo.\nBlaming them with \"Not Committed Yet\" is OK.\n\nThe solution is to revert commit 4d4813a5.\n\nReported-By: Stepan Kasal <kasal@ucw.cz>\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\nAdded test cases again.\nSince we have test files with only one line, grep should be OK\n builtin/blame.c               |  1 +\n t/t8003-blame-corner-cases.sh | 18 +++++++++++++++---\n 2 files changed, 16 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 06484c2..8d70623 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2348,6 +2348,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \t\tif (strbuf_read(&buf, 0, 0) < 0)\n \t\t\tdie_errno(\"failed to read from stdin\");\n \t}\n+\tconvert_to_git(path, buf.buf, buf.len, &buf, 0);\n \torigin->file.ptr = buf.buf;\n \torigin->file.size = buf.len;\n \tpretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1);\ndiff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh\nindex 32895e5..244959a 100755\n--- a/t/t8003-blame-corner-cases.sh\n+++ b/t/t8003-blame-corner-cases.sh\n@@ -191,12 +191,24 @@ test_expect_success 'indent of line numbers, ten lines' '\n \ttest $(grep -c \"  \" actual) = 9\n '\n \n-test_expect_success 'blaming files with CRLF newlines' '\n+test_expect_success 'setup file with CRLF newlines' '\n \tgit config core.autocrlf false &&\n-\tprintf \"testcase\\r\\n\" >crlffile &&\n+\tprintf \"testcase\\n\" >crlffile &&\n \tgit add crlffile &&\n \tgit commit -m testcase &&\n-\tgit -c core.autocrlf=input blame crlffile >actual &&\n+\tprintf \"testcase\\r\\n\" >crlffile\n+'\n+\n+test_expect_success 'blame file with CRLF core.autocrlf true' '\n+\tgit config core.autocrlf true &&\n+\tgit blame crlffile >actual &&\n+\tgrep \"A U Thor\" actual\n+'\n+\n+test_expect_success 'blaming files with CRLF attributes text' '\n+\tgit config core.autocrlf false &&\n+\techo \"crlffile text\" >.gitattributes &&\n+\tgit blame crlffile >actual &&\n \tgrep \"A U Thor\" actual\n '\n \n-- \n2.2.0.rc1.790.ge19fcd2\n"}]}