Skip to content

Commit 359f34f

Browse files
committed
Merge branch 'ks/blame-worktree-textconv-cached' into maint
* ks/blame-worktree-textconv-cached: fill_textconv(): Don't get/put cache if sha1 is not valid t/t8006: Demonstrate blame is broken when cachetextconv is on
2 parents 58c58c8 + 9ec09b0 commit 359f34f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4388,7 +4388,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
43884388
return df->size;
43894389
}
43904390

4391-
if (driver->textconv_cache) {
4391+
if (driver->textconv_cache && df->sha1_valid) {
43924392
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
43934393
&size);
43944394
if (*outbuf)
@@ -4399,7 +4399,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
43994399
if (!*outbuf)
44004400
die("unable to read files to diff");
44014401

4402-
if (driver->textconv_cache) {
4402+
if (driver->textconv_cache && df->sha1_valid) {
44034403
/* ignore errors, as we might be in a readonly repository */
44044404
notes_cache_put(driver->textconv_cache, df->sha1, *outbuf,
44054405
size);

t/t8006-blame-textconv.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ test_expect_success 'blame --textconv going through revisions' '
7373
test_cmp expected result
7474
'
7575

76+
test_expect_success 'setup +cachetextconv' '
77+
git config diff.test.cachetextconv true
78+
'
79+
80+
cat >expected_one <<EOF
81+
(Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
82+
EOF
83+
84+
test_expect_success 'blame --textconv works with textconvcache' '
85+
git blame --textconv two.bin >blame &&
86+
find_blame <blame >result &&
87+
test_cmp expected result &&
88+
git blame --textconv one.bin >blame &&
89+
find_blame <blame >result &&
90+
test_cmp expected_one result
91+
'
92+
93+
test_expect_success 'setup -cachetextconv' '
94+
git config diff.test.cachetextconv false
95+
'
96+
7697
test_expect_success 'make a new commit' '
7798
echo "bin: test number 2 version 3" >>two.bin &&
7899
GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"

0 commit comments

Comments
 (0)