MCPcopy
hub / github.com/git-lfs/git-lfs / newHandler

Function newHandler

lfshttp/standalone/standalone.go:174–207  ·  view source on GitHub ↗

newHandler creates a new handler for the protocol.

(cfg *config.Configuration, output *os.File, msg *inputMessage)

Source from the content-addressed store, hash-verified

172
173// newHandler creates a new handler for the protocol.
174func newHandler(cfg *config.Configuration, output *os.File, msg *inputMessage) (*fileHandler, error) {
175 url, err := fileUrlFromRemote(cfg, msg.Remote, msg.Operation)
176 if err != nil {
177 return nil, err
178 }
179 if url == nil {
180 return nil, errors.New(tr.Tr.Get("no valid file:// URLs found"))
181 }
182
183 path, err := tools.TranslateCygwinPath(fixUrlPath(url.Path))
184 if err != nil {
185 return nil, err
186 }
187
188 gitdir, err := gitDirAtPath(path)
189 if err != nil {
190 return nil, err
191 }
192
193 tempdir, err := os.MkdirTemp(cfg.TempDir(), "lfs-standalone-file-*")
194 if err != nil {
195 return nil, err
196 }
197
198 tracerx.Printf("using %q as remote git directory", gitdir)
199
200 return &fileHandler{
201 remotePath: path,
202 remoteConfig: config.NewIn(gitdir, gitdir),
203 output: output,
204 config: cfg,
205 tempdir: tempdir,
206 }, nil
207}
208
209// dispatch dispatches the event depending on the message type.
210func (h *fileHandler) dispatch(msg *inputMessage) bool {

Callers 1

ProcessStandaloneDataFunction · 0.85

Calls 8

NewFunction · 0.92
TranslateCygwinPathFunction · 0.92
NewInFunction · 0.92
fileUrlFromRemoteFunction · 0.85
fixUrlPathFunction · 0.85
gitDirAtPathFunction · 0.85
GetMethod · 0.65
TempDirMethod · 0.45

Tested by

no test coverage detected