Skip to content

Commit

Permalink
Merge branch 'ks/blame-worktree-textconv-cached'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gitster committed Dec 21, 2010
2 parents 3f246b1 + 9ec09b0 commit 6ae7a51
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions diff.c
Expand Up @@ -4412,7 +4412,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
return df->size;
}

if (driver->textconv_cache) {
if (driver->textconv_cache && df->sha1_valid) {
*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
&size);
if (*outbuf)
Expand All @@ -4423,7 +4423,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
if (!*outbuf)
die("unable to read files to diff");

if (driver->textconv_cache) {
if (driver->textconv_cache && df->sha1_valid) {
/* ignore errors, as we might be in a readonly repository */
notes_cache_put(driver->textconv_cache, df->sha1, *outbuf,
size);
Expand Down
21 changes: 21 additions & 0 deletions t/t8006-blame-textconv.sh
Expand Up @@ -73,6 +73,27 @@ test_expect_success 'blame --textconv going through revisions' '
test_cmp expected result
'

test_expect_success 'setup +cachetextconv' '
git config diff.test.cachetextconv true
'

cat >expected_one <<EOF
(Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
EOF

test_expect_success 'blame --textconv works with textconvcache' '
git blame --textconv two.bin >blame &&
find_blame <blame >result &&
test_cmp expected result &&
git blame --textconv one.bin >blame &&
find_blame <blame >result &&
test_cmp expected_one result
'

test_expect_success 'setup -cachetextconv' '
git config diff.test.cachetextconv false
'

test_expect_success 'make a new commit' '
echo "bin: test number 2 version 3" >>two.bin &&
GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
Expand Down

0 comments on commit 6ae7a51

Please sign in to comment.