Page MenuHomePhabricator

Manually prune Git working copy refs instead of using "--prune", to improve "Fetch Refs" behavior
ClosedPublic

Authored by epriestley on Nov 7 2019, 11:39 PM.
Tags
None
Referenced Files
F14096783: D20892.diff
Tue, Nov 26, 5:11 AM
Unknown Object (File)
Sat, Nov 23, 6:57 PM
Unknown Object (File)
Sat, Nov 16, 12:25 PM
Unknown Object (File)
Oct 23 2024, 12:13 PM
Unknown Object (File)
Oct 21 2024, 2:46 PM
Unknown Object (File)
Oct 20 2024, 3:43 PM
Unknown Object (File)
Oct 19 2024, 4:39 PM
Unknown Object (File)
Oct 1 2024, 7:56 PM
Subscribers
None

Details

Summary

Ref T13448. When "Fetch Refs" is configured:

  • We switch to a narrow mode when running "ls-remote" against the local working copy. This excludes surplus refs, so we'll incorrectly detect that the local and remote working copies are identical in cases where the local working copy really has surplus refs.
  • We rely on "--prune" to remove surplus local refs, but it only prunes refs matching the refspecs we pass "git fetch". Since these refspecs are very narrow under "Fetch Only", the pruning behavior is also very narrow.

Instead:

  • When listing local refs, always list everything. If we have too much stuff locally, we want to get rid of it.
  • When we identify surplus local refs, explicitly delete them instead of relying on "--prune". We can just do this in all cases so we don't have separate "--prune" and "manual" cases.
Test Plan
  • Created a new repository, observed from a GitHub repository, with many tags/refs/branches. Pulled it.
  • Observed lots of refs in git for-each-ref.
  • Changed "Fetch Refs" to "refs/heads/master".
  • Ran bin/repository pull X --trace --verbose.

On deciding to do something:

  • Before: since "master" did not change, the pull declined to act.
  • After: the pull detected surplus refs and deleted them. Since the states then matched, it declined further action.

On pruning:

  • Before: if the pull was forced to act, it ran "fetch --prune" with a narrow refspec, which did not prune the working copy.
  • After: saw working copy pruned explicitly with "update-ref -d" commands.

Also, set "Fetch Refs" back to the default (empty) and pulled, saw everything pull.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision was not accepted when it landed; it landed in state Needs Review.Nov 8 2019, 12:15 AM
This revision was automatically updated to reflect the committed changes.