Jonathan Tan <jonathantanmy@xxxxxxxxxx> writes: > In a partial clone, if a user provides the hash of the empty tree ("git > mktree </dev/null" - for SHA-1, this is 4b825d...) to a command which > requires that that object be parsed, for example: > > git diff-tree 4b825d <a non-empty tree> > > then Git will lazily fetch the empty tree. That sounds like a bug. Shouldn't some objects like empty tree and empty blob whose names are hardcoded come internally without being fetched from anywhere? > There are 2 functions: repo_has_object_file() which does not consult > find_cached_object() (which, among other things, knows about the empty > tree); and repo_read_object_file() which does. This issue occurs > because, as an optimization to avoid reading blobs into memory, > parse_object() calls repo_has_object_file() before > repo_read_object_file(). In the case of a regular repository (that is, > not a partial clone), repo_has_object_file() will return false for the > empty tree (thus bypassing the optimization) and... OK, that bypassing already sounds wrong. > ... it will no longer be the case that > repo_has_object_file() doesn't know about empty trees, but > repo_read_object_file() does. Yup, that sounds like the right solution to the bug, with or without lazy cloning.