Skip to content

fetch() does not update tracking refs when no new objects are needed #23

Closed

Description

@dnnsjsk

Repository::fetch() returns early when every advertised ref target already exists in the local object database (

pitmaster/src/Repository.php

Lines 1600 to 1602 in 5beb97d

if ($wants === []) {
return;
). The early return skips updateFetchedRefs() (
$this->updateFetchedRefs($trackedRefs, $discovery->refs());
), so remote-tracking refs are not moved in that case.

Examples where the objects are already present but the remote refs changed:

  • the remote branch was reset or force-pushed back to an older commit;
  • a new remote branch points at a commit that exists locally (for example a branch created on the server from main);
  • the commit was pushed from this repository with another tool, or fetched under a different remote name.

After fetch(), refs/remotes/<remote>/<branch> still shows the old value (or is missing), while git fetch updates it.

Expected

Skip only the pack request when there is nothing to download, and still update the tracking refs (and .git/shallow where relevant).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions