Jeff King <peff@xxxxxxxx> writes: > I agree this patch is fine, but I wonder if it could go even further. If > we are pretending some particular contents, shouldn't we override > anything that might be in the object database? I.e., could we eliminate > this has_object_file() entirely? > > That should be OK for the same reason that it's OK to use QUICK. > > There's only one caller of this function (git-blame), which I think > would be happy with such a change. I actually have to take that "we could even lie to say that content that does not hash to X is object X" back---that was never the intention of this mechanism. It was to ensure that operations that are supposedly read-only can avoid writing into the repository---"blame" uses it to pretend as if the working tree file already has a corresponding object in the object store, IIRC. The only reason why hash_object_file() is used here is to allow us discarding the memory held for that working tree copy if it happens to match what is stored in the object database. The saving would be within a few hundred kilobytes to a single digit megabyte range at most, hopefully, so we could drop it (oh, saying "a single digit megabyte" reminds me that my first Linux computer was 486dx with 4MB ram---on that box, it may have mattered).