Skip to content

gitserver: use fetch when cloning

Warren Gifford requested to merge k/fetch-only into main

Created by: keegancsmith

Instead of calling git clone, we can instead run git init followed by a git fetch. This allows us to remove clone specific code which duplicated logic between fetch and clone.

Additionally clone was the only place storing the remoteURL on disk for gitserver. So by relying on fetch we will not store the remoteURL on disk anymore. A separate commit will remove existing remoteURLs on disk.

Tomas and I audited the callsites which do remote calls and all of them specify the remoteURL as a command line argument. Additionally we never refer to a "git remote", so we don't need to store a git remote.

The only other setting we would get from clone is we set "--mirror". However, this didn't affect anything in our setup since:

  • We specify which refs to fetch
  • We never do a push without specifying a ref.

The only potential breaking change here is users of customFetchCmd. We are only aware of one customer using this. Now that we won't have a remote set, it is possible the customFetchCmd would break if it used it. We call this out explicitly in our CHANGELOG and will follow-up with Customer Engineering to ensure the potentially affected customer is aware. If it does affect them they can specify additional arguments to fetch (such as the remote URL) to unblock.

Co-authored-by: @tsenart

Merge request reports

Loading