Skip to content

Wouldn't it be nice to separate the fetch and push code out of remote.go? #1518

@mhagger

Description

@mhagger

There's not a lot of overlap between the code for fetching and the code for pushing. As a newcomer, I think the code would be easier to understand if these two aspects of a remote were each in their own separate file. By my reckoning, based on the v6-transfer branch (including a couple of my proposed changes), the separation would look something like this:

remote.go:

  • var NoErrAlreadyUpToDate
  • var ErrEmptyUrls
  • type Remote
  • func NewRemote()
  • func (r *Remote) IsAnonymous()
  • func (r *Remote) Config()
  • func (r *Remote) String()
  • func newClient()
  • func isFastForward()
  • func buildSidebandIfSupported() (not actually used)
  • func (r *Remote) ListContext()
  • func (r *Remote) List()
  • func (r *Remote) list()

remote_fetch.go:

  • var ErrForceNeeded
  • var ErrExactSHA1NotSupported
  • type NoMatchingRefSpecError
  • func (e NoMatchingRefSpecError) Error()
  • func (e NoMatchingRefSpecError) Is()
  • const maxHavesToVisitPerRef
  • const peeledSuffix
  • func (r *Remote) FetchContext()
  • func (r *Remote) Fetch()
  • func (r *Remote) fetch()
  • func referenceStorageFromRefs()
  • func depthChanged())
  • func (r *Remote) pruneRemotes()
  • func getRemoteRefsFromStorer()
  • func getHavesFromRef()
  • func getHaves()
  • const refspecAllTags
  • func calculateRefs()
  • func doCalculateRefs()
  • func getWants()
  • func objectExists()
  • func (r *Remote) isSupportedRefSpec()
  • func (r *Remote) updateLocalReferenceStorage()
  • func (r *Remote) buildFetchedTags()

remote_push.go:

  • var ErrDeleteRefNotSupported
  • func (r *Remote) Push()
  • func (r *Remote) PushContext()
  • func (r *Remote) sendPack()
  • func (r *Remote) useRefDeltas()
  • func (r *Remote) addReachableTags()
  • func (r *Remote) updateRemoteReferenceStorage()
  • func (r *Remote) addReferencesToUpdate()
  • func (r *Remote) addOrUpdateReferences()
  • func (r *Remote) deleteReferences()
  • func (r *Remote) addObject()
  • func (r *Remote) addReferenceIfRefSpecMatches()
  • func checkFastForwardUpdate()
  • func (r *Remote) checkForceWithLease()
  • func objectsToPush()
  • func referencesToHashes()
  • func pushHashes()
  • func (r *Remote) checkRequireRemoteRefs()

Similarly, remote_test.go could spawn new files remote_fetch_test.go and remote_push_test.go.

I'm not going to create a PR for this now, because the conflicts with any in-progress pull requests would be fierce. But maybe when this part of the code is in a more quiescent state, such a division would be worth considering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy