Skip to content

Commit 002dd77

Browse files
committed
Merge branch 'tb/blame-force-read-cache-to-workaround-safe-crlf' into maint
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
2 parents 18c554b + a08feb8 commit 002dd77

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
@@ -2307,6 +2307,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
23072307
unsigned mode;
23082308
struct strbuf msg = STRBUF_INIT;
23092309

2310+
read_cache();
23102311
time(&now);
23112312
commit = alloc_commit_node();
23122313
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)