do not write null sha1s to on-disk index
[git/git.git] / read-cache.c
index 274e54b..5ae7f2b 100644 (file)
@@ -1615,6 +1615,8 @@ int write_index(struct index_state *istate, int newfd)
                        continue;
                if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
                        ce_smudge_racily_clean_entry(ce);
+               if (is_null_sha1(ce->sha1))
+                       return error("cache entry has null sha1: %s", ce->name);
                if (ce_write_entry(&c, newfd, ce) < 0)
                        return -1;
        }