Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin/clone: allow remote helpers to detect repo #4908

Merged
merged 1 commit into from
Apr 12, 2024

Commits on Apr 12, 2024

  1. builtin/clone: allow remote helpers to detect repo

    In 18c9cb7 (builtin/clone: create the refdb with the correct object
    format, 2023-12-12), we have changed git-clone(1) so that it delays
    creation of the refdb until after it has learned about the remote's
    object format. This change was required for the reftable backend, which
    encodes the object format into the tables. So if we pre-initialized the
    refdb with the default object format, but the remote uses a different
    object format than that, then the resulting tables would have encoded
    the wrong object format.
    
    This change unfortunately breaks remote helpers which try to access the
    repository that is about to be created. Because the refdb has not yet
    been initialized at the point where we spawn the remote helper, we also
    don't yet have "HEAD" or "refs/". Consequently, any Git commands ran by
    the remote helper which try to access the repository would fail because
    it cannot be discovered.
    
    This is essentially a chicken-and-egg problem: we cannot initialize the
    refdb because we don't know about the object format. But we cannot learn
    about the object format because the remote helper may be unable to
    access the partially-initialized repository.
    
    Ideally, we would address this issue via capabilities. But the remote
    helper protocol is not structured in a way that guarantees that the
    capability announcement happens before the remote helper tries to access
    the repository.
    
    Instead, fix this issue by partially initializing the refdb up to the
    point where it becomes discoverable by Git commands.
    
    Reported-by: Mike Hommey <mh@glandium.org>
    Signed-off-by: Patrick Steinhardt <ps@pks.im>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Oliver Schneider <oschneider@exocad.com>
    pks-t authored and exoosh committed Apr 12, 2024
    Configuration menu
    Copy the full SHA
    729fd15 View commit details
    Browse the repository at this point in the history