]> granicus.if.org Git - git/commitdiff
correct blame for files commited with CRLF
authorTorsten Bögershausen <tboegi@web.de>
Tue, 5 Apr 2016 19:23:54 +0000 (21:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Apr 2016 20:55:30 +0000 (13:55 -0700)
git blame reports lines as not "Not Committed Yet" when they have
CRLF in the index, CRLF in the worktree and core.autocrlf is true.

Since commit c4805393 (autocrlf: Make it work also for un-normalized
repositories, 2010-05-12), files that have CRLF in the index are not
normalized at commit when core.autocrl is set.

Add a call to read_cache() early in fake_working_tree_commit(),
before calling convert_to_git().

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
t/t8003-blame-corner-cases.sh

index 048ed53c2f70961898d3d2a213e05315ae1ac92d..a5cabf79eaa7511495c19a4c53ac141344b0e888 100644 (file)
@@ -2275,6 +2275,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 16f1442c1e6e4780dc10474a3fbf516841468c9f..b8128b633480cce75dfe6fb48ef24034e69f595f 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