From: Kirill Smelkov Date: Sat, 18 Dec 2010 14:54:12 GMT Subject: [PATCH 2/2] fill_textconv(): Don't get/put cache if sha1 is not valid Message-ID: <14308c2dd50037246e319649944d308b9f32fc39.1292681111.git.kirr@landau.phys.spbu.ru> In-Reply-To: It turned out, under blame there are requests to fill_textconv() with sha1=0000000000000000000000000000000000000000 and sha1_valid=0. As the code did not analyzed sha1 validity, we ended up putting 000000 into textconv cache which was fooling later blames to discover lots of lines in 'Not Yet Committed' state. Fix it. Cc: Axel Bonnet Cc: Clément Poulain Cc: Diane Gasselin Cc: Jeff King Signed-off-by: Kirill Smelkov --- diff.c | 4 ++-- t/t8006-blame-textconv.sh | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/diff.c b/diff.c index 0a43869..5422c43 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 fe90541..ea64cd8 100755 --- a/t/t8006-blame-textconv.sh +++ b/t/t8006-blame-textconv.sh @@ -81,8 +81,7 @@ cat >expected_one <blame && find_blame result && test_cmp expected result && -- 1.7.3.4.570.g14308