Merge branch 'tb/blame-force-read-cache-to-workaround-safe-crlf' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2016 21:15:58 +0000 (14:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Apr 2016 21:15:58 +0000 (14:15 -0700)
When running "git blame $path" with unnormalized data in the index
for the path, the data in the working tree was blamed, even though
"git add" would not have changed what is already in the index, due
to "safe crlf" that disables the line-end conversion. It has been
corrected.

* tb/blame-force-read-cache-to-workaround-safe-crlf:
correct blame for files commited with CRLF

builtin/blame.c
t/t8003-blame-corner-cases.sh
index e982fb81379f57152e34eeda706a57fa1ea4c143..21f42b0b62b81b637f1cc9589cd6c0306a93d05e 100644 (file)
@@ -2307,6 +2307,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
        unsigned mode;
        struct strbuf msg = STRBUF_INIT;
 
+       read_cache();
        time(&now);
        commit = alloc_commit_node();
        commit->object.parsed = 1;
index 6568429753d5f90426ad6acc0703b79e9f7a3284..a9b266f0d3d029229a346fb21c703acb84e4c37d 100755 (executable)
@@ -212,4 +212,18 @@ test_expect_success 'blame file with CRLF attributes text' '
        grep "A U Thor" actual
 '
 
+test_expect_success 'blame file with CRLF core.autocrlf=true' '
+       git config core.autocrlf false &&
+       printf "testcase\r\n" >crlfinrepo &&
+       >.gitattributes &&
+       git add crlfinrepo &&
+       git commit -m "add crlfinrepo" &&
+       git config core.autocrlf true &&
+       mv crlfinrepo tmp &&
+       git checkout crlfinrepo &&
+       rm tmp &&
+       git blame crlfinrepo >actual &&
+       grep "A U Thor" actual
+'
+
 test_done