Kirill Smelkov  committed 9ec09b0

fill_textconv(): Don't get/put cache if sha1 is not valid

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 <>

  • Participants
  • Parent commits b1b14ec

Comments (0)

Files changed (2)

 		return df->size;
-	if (driver->textconv_cache) {
+	if (driver->textconv_cache && df->sha1_valid) {
 		*outbuf = notes_cache_get(driver->textconv_cache, df->sha1,
 		if (*outbuf)
 	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,

File t/

 (Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
-# one.bin is blamed as 'Not Committed yet'
-test_expect_failure 'blame --textconv works with textconvcache' '
+test_expect_success 'blame --textconv works with textconvcache' '
 	git blame --textconv two.bin >blame &&
 	find_blame <blame >result &&
 	test_cmp expected result &&