From: Junio C Hamano Date: Tue, 21 Dec 2010 22:30:52 +0000 (-0800) Subject: Merge branch 'ks/blame-worktree-textconv-cached' X-Git-Tag: v1.7.4-rc0~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6ae7a51a2e8efdb10c18d59693e647a73d98d9d3?hp=3f246b1cef2c568bbac1f71c25fbf8045ff6448a 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 --- diff --git a/diff.c b/diff.c index 0a43869435..5422c43882 100644 --- a/diff.c +++ b/diff.c @@ -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) @@ -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); diff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh index dbf623bce5..ea64cd8d0f 100755 --- a/t/t8006-blame-textconv.sh +++ b/t/t8006-blame-textconv.sh @@ -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 <blame && + find_blame result && + test_cmp expected result && + git blame --textconv one.bin >blame && + find_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"