Skip to content

Commit 2113021

Browse files
committed
Merge pull request #138 from tboegi/150504_blame-resurrect-convert-to-git
blame: CRLF in the working tree and LF in the repo
2 parents b058360 + 8354b03 commit 2113021

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

builtin/blame.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
23482348
if (strbuf_read(&buf, 0, 0) < 0)
23492349
die_errno("failed to read from stdin");
23502350
}
2351+
convert_to_git(path, buf.buf, buf.len, &buf, 0);
23512352
origin->file.ptr = buf.buf;
23522353
origin->file.size = buf.len;
23532354
pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1);

t/t8003-blame-corner-cases.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,24 @@ test_expect_success 'indent of line numbers, ten lines' '
191191
test $(grep -c " " actual) = 9
192192
'
193193

194-
test_expect_success 'blaming files with CRLF newlines' '
194+
test_expect_success 'setup file with CRLF newlines' '
195195
git config core.autocrlf false &&
196-
printf "testcase\r\n" >crlffile &&
196+
printf "testcase\n" >crlffile &&
197197
git add crlffile &&
198198
git commit -m testcase &&
199-
git -c core.autocrlf=input blame crlffile >actual &&
199+
printf "testcase\r\n" >crlffile
200+
'
201+
202+
test_expect_success 'blame file with CRLF core.autocrlf true' '
203+
git config core.autocrlf true &&
204+
git blame crlffile >actual &&
205+
grep "A U Thor" actual
206+
'
207+
208+
test_expect_success 'blame file with CRLF attributes text' '
209+
git config core.autocrlf false &&
210+
echo "crlffile text" >.gitattributes &&
211+
git blame crlffile >actual &&
200212
grep "A U Thor" actual
201213
'
202214

0 commit comments

Comments
 (0)