From 9ec09b0495f5e672223025f5e681371034da2538 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sat, 18 Dec 2010 17:54:12 +0300 Subject: [PATCH] fill_textconv(): Don't get/put cache if sha1 is not valid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When blaming files in the working tree, the filespec is marked with !sha1_valid, as we have not given the contents an object name yet. The function to cache textconv results (keyed on the object name), however, didn't check this condition, and ended up on storing the cached result under a random object name. Cc: Axel Bonnet Cc: Clément Poulain Cc: Diane Gasselin Cc: Jeff King Signed-off-by: Kirill Smelkov Signed-off-by: Junio C Hamano --- 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 8256f313e..fa3b29d92 100644 --- a/diff.c +++ b/diff.c @@ -4388,7 +4388,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) @@ -4399,7 +4399,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 fe9054184..ea64cd8d0 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 && -- 2.30.2