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

Function startConnection

ssh/connection.go:43–88  ·  view source on GitHub ↗
(id int, osEnv config.Environment, gitEnv config.Environment, meta *SSHMetadata, operation string, multiplexControlPath string)

Source from the content-addressed store, hash-verified

41}
42
43func startConnection(id int, osEnv config.Environment, gitEnv config.Environment, meta *SSHMetadata, operation string, multiplexControlPath string) (conn *PktlineConnection, multiplexing bool, controlPath string, err error) {
44 tracerx.Printf("spawning pure SSH connection (#%d)", id)
45 var errbuf bytes.Buffer
46 exe, args, multiplexing, controlPath := GetLFSExeAndArgs(osEnv, gitEnv, meta, "git-lfs-transfer", operation, true, multiplexControlPath)
47 cmd, err := subprocess.ExecCommand(exe, args...)
48 if err != nil {
49 return nil, false, "", err
50 }
51 r, err := cmd.StdoutPipe()
52 if err != nil {
53 return nil, false, "", err
54 }
55 w, err := cmd.StdinPipe()
56 if err != nil {
57 return nil, false, "", err
58 }
59 cmd.Stderr = &errbuf
60 err = cmd.Start()
61 if err != nil {
62 return nil, false, "", err
63 }
64
65 var pl Pktline
66 if osEnv.Bool("GIT_TRACE_PACKET", false) {
67 pl = &TraceablePktline{id: id, pl: pktline.NewPktline(r, w)}
68 } else {
69 pl = pktline.NewPktline(r, w)
70 }
71 conn = &PktlineConnection{
72 cmd: cmd,
73 pl: pl,
74 r: r,
75 w: w,
76 }
77 err = conn.Start()
78 if err != nil {
79 r.Close()
80 w.Close()
81 cmd.Wait()
82 err = errors.Join(err, errors.New(tr.Tr.Get("Failed to connect to remote SSH server: %s", cmd.Stderr)))
83 tracerx.Printf("pure SSH connection unsuccessful (#%d)", id)
84 } else {
85 tracerx.Printf("pure SSH connection successful (#%d)", id)
86 }
87 return conn, multiplexing, controlPath, err
88}
89
90// Connection returns the nth connection (starting from 0) in this transfer
91// instance or nil if there is no such item.

Callers 2

NewSSHTransferFunction · 0.85
spawnConnectionMethod · 0.85

Calls 11

ExecCommandFunction · 0.92
JoinFunction · 0.92
NewFunction · 0.92
GetLFSExeAndArgsFunction · 0.85
StdoutPipeMethod · 0.80
StdinPipeMethod · 0.80
BoolMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.65
GetMethod · 0.65
StartMethod · 0.45

Tested by

no test coverage detected