commands: avoid remote connections in checkout
Right now, creating a checkout object as used by the checkout and pull commands creates a manifest. This manifest in turn creates an SSHTransfer object to potentially connect via the new pure SSH protocol. However, connecting to the Internet during `git lfs checkout` is unexpected and may cause this operation to fail when one is not online. In order to set the manifest's configuration parameters correctly, we need to know whether it's possible to make a pure SSH protocol connection, so it's non-trivial to avoid this connection by delaying the initialization of SSHTransfer object. Instead, let's lazily create our manifest in the checkout code to avoid creating the connection. If we're performing a `git lfs pull`, then it will be used and we'll initialize it very quickly, making the connection, and if we're using `git lfs checkout`, it won't be initialized at all, and we'll remain offline.
This commit is contained in:
parent
18959fcb22
commit
fc463f7061
@ -18,11 +18,9 @@ import (
|
||||
// Handles the process of checking out a single file, and updating the git
|
||||
// index.
|
||||
func newSingleCheckout(gitEnv config.Environment, remote string) abstractCheckout {
|
||||
manifest := getTransferManifestOperationRemote("download", remote)
|
||||
|
||||
clean, ok := gitEnv.Get("filter.lfs.clean")
|
||||
if !ok || len(clean) == 0 {
|
||||
return &noOpCheckout{manifest: manifest}
|
||||
return &noOpCheckout{remote: remote}
|
||||
}
|
||||
|
||||
// Get a converter from repo-relative to cwd-relative
|
||||
@ -35,7 +33,8 @@ func newSingleCheckout(gitEnv config.Environment, remote string) abstractCheckou
|
||||
return &singleCheckout{
|
||||
gitIndexer: &gitIndexer{},
|
||||
pathConverter: pathConverter,
|
||||
manifest: manifest,
|
||||
manifest: nil,
|
||||
remote: remote,
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,9 +50,13 @@ type singleCheckout struct {
|
||||
gitIndexer *gitIndexer
|
||||
pathConverter lfs.PathConverter
|
||||
manifest *tq.Manifest
|
||||
remote string
|
||||
}
|
||||
|
||||
func (c *singleCheckout) Manifest() *tq.Manifest {
|
||||
if c.manifest == nil {
|
||||
c.manifest = getTransferManifestOperationRemote("download", c.remote)
|
||||
}
|
||||
return c.manifest
|
||||
}
|
||||
|
||||
@ -113,9 +116,13 @@ func (c *singleCheckout) Close() {
|
||||
|
||||
type noOpCheckout struct {
|
||||
manifest *tq.Manifest
|
||||
remote string
|
||||
}
|
||||
|
||||
func (c *noOpCheckout) Manifest() *tq.Manifest {
|
||||
if c.manifest == nil {
|
||||
c.manifest = getTransferManifestOperationRemote("download", c.remote)
|
||||
}
|
||||
return c.manifest
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user