Skip to content

Commit 9588bc1

Browse files
committed
Merge branch 'ss/blame-textconv-fake-working-tree' into next
* ss/blame-textconv-fake-working-tree: (squash) test for previous blame.c: Properly initialize strbuf after calling, textconv_object() Conflicts: t/t8006-blame-textconv.sh
2 parents 5267fa3 + 55e7c0a commit 9588bc1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

builtin/blame.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,8 +2113,10 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
21132113
switch (st.st_mode & S_IFMT) {
21142114
case S_IFREG:
21152115
if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
2116-
textconv_object(read_from, mode, null_sha1, &buf.buf, &buf_len))
2116+
textconv_object(read_from, mode, null_sha1, &buf.buf, &buf_len)) {
2117+
buf.alloc = buf_len;
21172118
buf.len = buf_len;
2119+
}
21182120
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
21192121
die_errno("cannot open or read '%s'", read_from);
21202122
break;

t/t8006-blame-textconv.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EOF
1515
chmod +x helper
1616

1717
test_expect_success 'setup ' '
18+
echo "bin: test number 0" >zero.bin &&
1819
echo "bin: test 1" >one.bin &&
1920
echo "bin: test number 2" >two.bin &&
2021
if test_have_prereq SYMLINKS; then
@@ -43,6 +44,7 @@ test_expect_success 'no filter specified' '
4344

4445
test_expect_success 'setup textconv filters' '
4546
echo "*.bin diff=test" >.gitattributes &&
47+
echo "zero.bin eol=crlf" >>.gitattributes &&
4648
git config diff.test.textconv ./helper &&
4749
git config diff.test.cachetextconv false
4850
'
@@ -74,6 +76,15 @@ test_expect_success 'blame --textconv going through revisions' '
7476
test_cmp expected result
7577
'
7678

79+
test_expect_success 'blame --textconv with local changes' '
80+
test_when_finished "git checkout zero.bin" &&
81+
printf "bin: updated number 0\015" >zero.bin &&
82+
git blame --textconv zero.bin >blame &&
83+
expect="(Not Committed Yet ....-..-.. ..:..:.. +0000 1)" &&
84+
expect="$expect converted: updated number 0" &&
85+
expr "$(find_blame <blame)" : "^$expect"
86+
'
87+
7788
test_expect_success 'setup +cachetextconv' '
7889
git config diff.test.cachetextconv true
7990
'

0 commit comments

Comments
 (0)