Skip to content

Commit a08feb8

Browse files
tboegigitster
authored andcommitted
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 c480539 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7654286 commit a08feb8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

builtin/blame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
22752275
unsigned mode;
22762276
struct strbuf msg = STRBUF_INIT;
22772277

2278+
read_cache();
22782279
time(&now);
22792280
commit = alloc_commit_node();
22802281
commit->object.parsed = 1;

t/t8003-blame-corner-cases.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,18 @@ test_expect_success 'blame file with CRLF attributes text' '
212212
grep "A U Thor" actual
213213
'
214214

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+
215229
test_done

0 commit comments

Comments
 (0)