correct blame for files commited with CRLF
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>
Torsten Bögershausen committed
Apr 5, 2016 at 21:23 UTC
a08feb8ef0b66c3e7d398ee6169c607b8efb7c80
2 files changed
+15
builtin/blame.c
+1
@@ -2275,6 +2275,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2275
unsigned mode;
2276
struct strbuf msg = STRBUF_INIT;
2277
2278
+ read_cache();
2279
time(&now);
2280
commit = alloc_commit_node();
2281
commit->object.parsed = 1;
t/t8003-blame-corner-cases.sh
+14
@@ -212,4 +212,18 @@ test_expect_success 'blame file with CRLF attributes text' '
212
grep "A U Thor" actual
213
'
214
215
+test_expect_success 'blame file with CRLF core.autocrlf=true' '
216
+ git config core.autocrlf false &&
217
+ printf "testcase\r\n" >crlfinrepo &&
218
+ >.gitattributes &&
219
+ git add crlfinrepo &&
220
+ git commit -m "add crlfinrepo" &&
221
+ git config core.autocrlf true &&
222
+ mv crlfinrepo tmp &&
223
+ git checkout crlfinrepo &&
224
+ rm tmp &&
225
+ git blame crlfinrepo >actual &&
226
+ grep "A U Thor" actual
227
+'
228
+
229
test_done