← 输入框|github.com|刷新
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: test
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Oct 14, 2026

  1. connected: negate alternate refs in deepening fetches too

    The connectivity check spawned by check_connected() uses
    
      git rev-list --objects --stdin --not --all --quiet --alternate-refs
    
    where 39b44ba (check_everything_connected: assume alternate ref
    tips are valid, 2019-07-01) added "--alternate-refs" so that the walk
    from the fetched tips stops at the refs of any alternate object store,
    on the assumption that the alternate is already fully connected.
    
    That only works because "--alternate-refs" comes after "--not".
    cf1e7c0 (fetch-pack: write shallow, then check connectivity,
    2018-07-02) drops "--not --all" for deepening fetches, since those
    need to verify the whole chain up to the new shallow boundary rather
    than stopping at refs we already had. For such fetches we therefore
    run
    
      git --shallow-file ... rev-list --objects --stdin --quiet --alternate-refs
    
    with the alternate's refs as positive revisions, and rev-list
    enumerates every object reachable from them. Unless one of those refs
    happens to lie inside the newly fetched shallow range, where the
    grafts cut the walk short, that is the alternate's entire history.
    
    This is slow for setups that attach a large alternate to a fresh
    repository and then do a shallow fetch of a ref that is a few commits
    ahead of the alternate, which is how CI runners share a clone of a
    big repository between jobs. With a 7M-object alternate (a bare clone
    of gitlab-org/gitlab), "git fetch --depth 1" transfers an empty pack
    in under a second and the connectivity check then takes 227s. With
    the alternate's refs negated the same rev-list finishes in 0.0s.
    
    Pass "--not" in both cases, before the branch that adds "--all" for
    non-deepening fetches, so that "--alternate-refs" is negated for
    deepening fetches as well. Such a fetch still has to reach the new
    shallow boundary from the fetched tips without stopping at our own
    refs, which is what cf1e7c0 wanted. It stops at the alternate's
    refs, as every other fetch already does. Move "--alternate-refs" up
    next to "--all" so that the arguments that bound the walk are in one
    place.
    
    Add tests to t5618 that check the arguments of the rev-list child via
    GIT_TRACE2_EVENT for a regular and for a deepening fetch. The result
    of the check is the same either way for a complete alternate, so
    there is no behavioural difference to assert on. The difference is
    only in which objects are walked.
    
    Helped-by: Patrick Steinhardt <ps@pks.im>
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Igor Wiedler <iwiedler@gitlab.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    igorwwwwwwwwwwwwwwwwwwww authored and gitster committed Oct 14, 2026
    Configuration menu
    Copy the full SHA
    5c8976e View commit details
    Browse the repository at this point in the history
  2. odb: ignore refs of shallow and grafted alternates

    odb_for_each_alternate_ref() reports the refs of every alternate
    object store that is a repository. Its three callers use them as
    commits whose history can be assumed to be present: "rev-list
    --alternate-refs" (and through it the connectivity check after a
    fetch), fetch-pack, which sends them as "have"s so that the server
    does not resend what the alternate has, and receive-pack, which
    advertises them as ".have".
    
    That assumption does not hold for a shallow repository, whose refs
    point at commits with no history behind them below its shallow
    boundary, nor for a grafted one. A repository borrowing objects from
    such an alternate does not see the alternate's shallow file, so the
    history that is missing there is missing here as well. The fetch then
    succeeds, the connectivity check stops at the alternate's refs, and
    a later "git log" fails with "Could not read <oid>".
    
    "git clone --reference" already rejects a shallow or grafted
    reference repository for this reason, but nothing prevents such a
    repository from being added via objects/info/alternates or
    GIT_ALTERNATE_OBJECT_DIRECTORIES, or from being made shallow after
    other repositories started borrowing from it.
    
    Skip the refs of an alternate that has a "shallow" file or an
    "info/grafts" file, the same checks clone uses. Its objects are still
    available through the object store. Only its refs are no longer used
    as a boundary.
    
    Partial clones have the same problem for the objects they lack, but
    detecting one requires reading the alternate's config, so this
    patch does not handle them.
    
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Signed-off-by: Igor Wiedler <iwiedler@gitlab.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    igorwwwwwwwwwwwwwwwwwwww authored and gitster committed Oct 14, 2026
    Configuration menu
    Copy the full SHA
    24e67bf View commit details
    Browse the repository at this point in the history
Loading