Re: [PATCH] sha1-file: remove OBJECT_INFO_SKIP_CACHED
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 30, 2019, 21:43 UTC
- Message-ID
- <xmqqsgl1fq03.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20191230211027.37002-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 7 quoted lines
> 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?
Show 8 quoted lines
> 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.