Skip to content

Commit 6ae7a51

Browse files
committed
Merge branch 'ks/blame-worktree-textconv-cached'
* 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 3f246b1 + 9ec09b0 commit 6ae7a51

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
@@ -4412,7 +4412,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
44124412
return df->size;
44134413
}
44144414

4415-
if (driver->textconv_cache) {
4415+
if (driver->textconv_cache && df->sha1_valid) {
44164416
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
44174417
&size);
44184418
if (*outbuf)
@@ -4423,7 +4423,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
44234423
if (!*outbuf)
44244424
die("unable to read files to diff");
44254425

4426-
if (driver->textconv_cache) {
4426+
if (driver->textconv_cache && df->sha1_valid) {
44274427
/* ignore errors, as we might be in a readonly repository */
44284428
notes_cache_put(driver->textconv_cache, df->sha1, *outbuf,
44294429
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)