git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] sha1-file: remove OBJECT_INFO_SKIP_CACHED
Date: Mon, 30 Dec 2019 13:43:56 -0800	[thread overview]
Message-ID: <xmqqsgl1fq03.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191230211027.37002-1-jonathantanmy@google.com> (Jonathan Tan's message of "Mon, 30 Dec 2019 13:10:27 -0800")

Jonathan Tan <jonathantanmy@google.com> 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.

  reply	other threads:[~2019-12-30 21:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 21:10 [PATCH] sha1-file: remove OBJECT_INFO_SKIP_CACHED Jonathan Tan
2019-12-30 21:43 ` Junio C Hamano [this message]
2019-12-30 22:01 ` Jonathan Nieder
2019-12-31  0:39   ` Jonathan Tan
2019-12-31  1:03     ` Jonathan Nieder
2020-01-02 20:15 ` Jonathan Tan
2020-01-02 20:16 ` [PATCH v2] " Jonathan Tan
2020-01-02 21:41   ` Junio C Hamano
2020-01-06 21:14     ` Jeff King
2020-01-04  0:13   ` Jonathan Nieder
2020-01-06 21:17     ` Jeff King
2020-01-06 23:47       ` Jonathan Nieder
2020-01-07 11:22         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqsgl1fq03.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).