Skip to content

Commit 3b3724d

Browse files
committed
ssh/ssh*.go: drop unused FormatArgs() arguments
In commit b44cbe4 of PR git-lfs#5136 the "multiplex" argument was added to the FormatArgs() function in our ssh/ssh.go source file. Later, the "controlPath" argument was also added, in commit 448b0c4 of PR git-lfs#5537. Neither of these arguments is used in the function's body, though, so we can remove them now.
1 parent 52199c7 commit 3b3724d

File tree

2 files changed

+51
-28
lines changed

2 files changed

+51
-28
lines changed

ssh/ssh.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type SSHMetadata struct {
3030
Path string
3131
}
3232

33-
func FormatArgs(cmd string, args []string, needShell bool, multiplex bool, controlPath string) (string, []string) {
33+
func FormatArgs(cmd string, args []string, needShell bool) (string, []string) {
3434
if !needShell {
3535
return cmd, args
3636
}
@@ -41,7 +41,7 @@ func FormatArgs(cmd string, args []string, needShell bool, multiplex bool, contr
4141
func GetLFSExeAndArgs(osEnv config.Environment, gitEnv config.Environment, meta *SSHMetadata, command, operation string, multiplexDesired bool, multiplexControlPath string) (exe string, args []string, multiplexing bool, controlPath string) {
4242
exe, args, needShell, multiplexing, controlPath := GetExeAndArgs(osEnv, gitEnv, meta, multiplexDesired, multiplexControlPath)
4343
args = append(args, fmt.Sprintf("%s %s %s", command, meta.Path, operation))
44-
exe, args = FormatArgs(exe, args, needShell, multiplexing, controlPath)
44+
exe, args = FormatArgs(exe, args, needShell)
4545
tracerx.Printf("run_command: %s %s", exe, strings.Join(args, " "))
4646
return exe, args, multiplexing, controlPath
4747
}

ssh/ssh_test.go

+49-26
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func TestSSHGetExeAndArgsSsh(t *testing.T) {
4545
meta := ssh.SSHMetadata{}
4646
meta.UserAndHost = "[email protected]"
4747

48-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
48+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
49+
exe, args = ssh.FormatArgs(exe, args, needShell)
4950
assert.Equal(t, "ssh", exe)
5051
assert.Equal(t, []string{"[email protected]"}, args)
5152
}
@@ -61,7 +62,8 @@ func TestSSHGetExeAndArgsSshCustomPort(t *testing.T) {
6162
meta.UserAndHost = "[email protected]"
6263
meta.Port = "8888"
6364

64-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
65+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
66+
exe, args = ssh.FormatArgs(exe, args, needShell)
6567
assert.Equal(t, "ssh", exe)
6668
assert.Equal(t, []string{"-p", "8888", "[email protected]"}, args)
6769
}
@@ -79,7 +81,7 @@ func TestSSHGetExeAndArgsSshNoMultiplexing(t *testing.T) {
7981
meta.UserAndHost = "[email protected]"
8082

8183
exe, baseargs, needShell, multiplexing, controlPath := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, true, "")
82-
exe, args := ssh.FormatArgs(exe, baseargs, needShell, multiplexing, controlPath)
84+
exe, args := ssh.FormatArgs(exe, baseargs, needShell)
8385
assert.Equal(t, "ssh", exe)
8486
assert.Equal(t, false, multiplexing)
8587
assert.Equal(t, []string{"[email protected]"}, args)
@@ -99,7 +101,7 @@ func TestSSHGetExeAndArgsSshMultiplexingMaster(t *testing.T) {
99101
meta.UserAndHost = "[email protected]"
100102

101103
exe, baseargs, needShell, multiplexing, controlPath := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, true, "")
102-
exe, args := ssh.FormatArgs(exe, baseargs, needShell, multiplexing, controlPath)
104+
exe, args := ssh.FormatArgs(exe, baseargs, needShell)
103105
assert.Equal(t, "ssh", exe)
104106
assert.Equal(t, true, multiplexing)
105107
assert.Equal(t, 3, len(args))
@@ -122,7 +124,7 @@ func TestSSHGetExeAndArgsSshMultiplexingExtra(t *testing.T) {
122124
meta.UserAndHost = "[email protected]"
123125

124126
exe, baseargs, needShell, multiplexing, controlPath := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, true, "/tmp/lfs/lfs.sock")
125-
exe, args := ssh.FormatArgs(exe, baseargs, needShell, multiplexing, controlPath)
127+
exe, args := ssh.FormatArgs(exe, baseargs, needShell)
126128
assert.Equal(t, "ssh", exe)
127129
assert.Equal(t, true, multiplexing)
128130
assert.Equal(t, []string{"-oControlMaster=no", "-oControlPath=/tmp/lfs/lfs.sock", "[email protected]"}, args)
@@ -141,7 +143,8 @@ func TestSSHGetExeAndArgsPlink(t *testing.T) {
141143
meta := ssh.SSHMetadata{}
142144
meta.UserAndHost = "[email protected]"
143145

144-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
146+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
147+
exe, args = ssh.FormatArgs(exe, args, needShell)
145148
assert.Equal(t, plink, exe)
146149
assert.Equal(t, []string{"[email protected]"}, args)
147150
}
@@ -159,7 +162,8 @@ func TestSSHGetExeAndArgsPlinkCustomPort(t *testing.T) {
159162
meta.UserAndHost = "[email protected]"
160163
meta.Port = "8888"
161164

162-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
165+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
166+
exe, args = ssh.FormatArgs(exe, args, needShell)
163167
assert.Equal(t, plink, exe)
164168
assert.Equal(t, []string{"-P", "8888", "[email protected]"}, args)
165169
}
@@ -178,7 +182,8 @@ func TestSSHGetExeAndArgsPlinkCustomPortExplicitEnvironment(t *testing.T) {
178182
meta.UserAndHost = "[email protected]"
179183
meta.Port = "8888"
180184

181-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
185+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
186+
exe, args = ssh.FormatArgs(exe, args, needShell)
182187
assert.Equal(t, plink, exe)
183188
assert.Equal(t, []string{"-P", "8888", "[email protected]"}, args)
184189
}
@@ -197,7 +202,8 @@ func TestSSHGetExeAndArgsPlinkCustomPortExplicitEnvironmentPutty(t *testing.T) {
197202
meta.UserAndHost = "[email protected]"
198203
meta.Port = "8888"
199204

200-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
205+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
206+
exe, args = ssh.FormatArgs(exe, args, needShell)
201207
assert.Equal(t, plink, exe)
202208
assert.Equal(t, []string{"-P", "8888", "[email protected]"}, args)
203209
}
@@ -216,7 +222,8 @@ func TestSSHGetExeAndArgsPlinkCustomPortExplicitEnvironmentSsh(t *testing.T) {
216222
meta.UserAndHost = "[email protected]"
217223
meta.Port = "8888"
218224

219-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
225+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
226+
exe, args = ssh.FormatArgs(exe, args, needShell)
220227
assert.Equal(t, plink, exe)
221228
assert.Equal(t, []string{"-p", "8888", "[email protected]"}, args)
222229
}
@@ -233,7 +240,8 @@ func TestSSHGetExeAndArgsTortoisePlink(t *testing.T) {
233240
meta := ssh.SSHMetadata{}
234241
meta.UserAndHost = "[email protected]"
235242

236-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
243+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
244+
exe, args = ssh.FormatArgs(exe, args, needShell)
237245
assert.Equal(t, plink, exe)
238246
assert.Equal(t, []string{"-batch", "[email protected]"}, args)
239247
}
@@ -251,7 +259,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCustomPort(t *testing.T) {
251259
meta.UserAndHost = "[email protected]"
252260
meta.Port = "8888"
253261

254-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
262+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
263+
exe, args = ssh.FormatArgs(exe, args, needShell)
255264
assert.Equal(t, plink, exe)
256265
assert.Equal(t, []string{"-batch", "-P", "8888", "[email protected]"}, args)
257266
}
@@ -270,7 +279,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCustomPortExplicitEnvironment(t *testing.T
270279
meta.UserAndHost = "[email protected]"
271280
meta.Port = "8888"
272281

273-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
282+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
283+
exe, args = ssh.FormatArgs(exe, args, needShell)
274284
assert.Equal(t, plink, exe)
275285
assert.Equal(t, []string{"-batch", "-P", "8888", "[email protected]"}, args)
276286
}
@@ -291,7 +301,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCustomPortExplicitConfig(t *testing.T) {
291301
meta.UserAndHost = "[email protected]"
292302
meta.Port = "8888"
293303

294-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
304+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
305+
exe, args = ssh.FormatArgs(exe, args, needShell)
295306
assert.Equal(t, plink, exe)
296307
assert.Equal(t, []string{"-batch", "-P", "8888", "[email protected]"}, args)
297308
}
@@ -311,7 +322,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCustomPortExplicitConfigOverride(t *testin
311322
meta.UserAndHost = "[email protected]"
312323
meta.Port = "8888"
313324

314-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
325+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
326+
exe, args = ssh.FormatArgs(exe, args, needShell)
315327
assert.Equal(t, plink, exe)
316328
assert.Equal(t, []string{"-P", "8888", "[email protected]"}, args)
317329
}
@@ -327,7 +339,8 @@ func TestSSHGetExeAndArgsSshCommandPrecedence(t *testing.T) {
327339
meta := ssh.SSHMetadata{}
328340
meta.UserAndHost = "[email protected]"
329341

330-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
342+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
343+
exe, args = ssh.FormatArgs(exe, args, needShell)
331344
assert.Equal(t, "sh", exe)
332345
assert.Equal(t, []string{"-c", "sshcmd [email protected]"}, args)
333346
}
@@ -342,7 +355,8 @@ func TestSSHGetExeAndArgsSshCommandArgs(t *testing.T) {
342355
meta := ssh.SSHMetadata{}
343356
meta.UserAndHost = "[email protected]"
344357

345-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
358+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
359+
exe, args = ssh.FormatArgs(exe, args, needShell)
346360
assert.Equal(t, "sh", exe)
347361
assert.Equal(t, []string{"-c", "sshcmd --args 1 [email protected]"}, args)
348362
}
@@ -357,7 +371,8 @@ func TestSSHGetExeAndArgsSshCommandArgsWithMixedQuotes(t *testing.T) {
357371
meta := ssh.SSHMetadata{}
358372
meta.UserAndHost = "[email protected]"
359373

360-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
374+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
375+
exe, args = ssh.FormatArgs(exe, args, needShell)
361376
assert.Equal(t, "sh", exe)
362377
assert.Equal(t, []string{"-c", "sshcmd foo 'bar \"baz\"' [email protected]"}, args)
363378
}
@@ -372,7 +387,8 @@ func TestSSHGetExeAndArgsSshCommandCustomPort(t *testing.T) {
372387
meta.UserAndHost = "[email protected]"
373388
meta.Port = "8888"
374389

375-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
390+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
391+
exe, args = ssh.FormatArgs(exe, args, needShell)
376392
assert.Equal(t, "sh", exe)
377393
assert.Equal(t, []string{"-c", "sshcmd -p 8888 [email protected]"}, args)
378394
}
@@ -388,7 +404,8 @@ func TestSSHGetExeAndArgsCoreSshCommand(t *testing.T) {
388404
meta := ssh.SSHMetadata{}
389405
meta.UserAndHost = "[email protected]"
390406

391-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
407+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
408+
exe, args = ssh.FormatArgs(exe, args, needShell)
392409
assert.Equal(t, "sh", exe)
393410
assert.Equal(t, []string{"-c", "sshcmd --args 2 [email protected]"}, args)
394411
}
@@ -402,7 +419,8 @@ func TestSSHGetExeAndArgsCoreSshCommandArgsWithMixedQuotes(t *testing.T) {
402419
meta := ssh.SSHMetadata{}
403420
meta.UserAndHost = "[email protected]"
404421

405-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
422+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
423+
exe, args = ssh.FormatArgs(exe, args, needShell)
406424
assert.Equal(t, "sh", exe)
407425
assert.Equal(t, []string{"-c", "sshcmd foo 'bar \"baz\"' [email protected]"}, args)
408426
}
@@ -416,7 +434,8 @@ func TestSSHGetExeAndArgsConfigVersusEnv(t *testing.T) {
416434
meta := ssh.SSHMetadata{}
417435
meta.UserAndHost = "[email protected]"
418436

419-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
437+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
438+
exe, args = ssh.FormatArgs(exe, args, needShell)
420439
assert.Equal(t, "sh", exe)
421440
assert.Equal(t, []string{"-c", "sshcmd --args 1 [email protected]"}, args)
422441
}
@@ -432,7 +451,8 @@ func TestSSHGetExeAndArgsPlinkCommand(t *testing.T) {
432451
meta := ssh.SSHMetadata{}
433452
meta.UserAndHost = "[email protected]"
434453

435-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
454+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
455+
exe, args = ssh.FormatArgs(exe, args, needShell)
436456
assert.Equal(t, "sh", exe)
437457
assert.Equal(t, []string{"-c", plink + " [email protected]"}, args)
438458
}
@@ -449,7 +469,8 @@ func TestSSHGetExeAndArgsPlinkCommandCustomPort(t *testing.T) {
449469
meta.UserAndHost = "[email protected]"
450470
meta.Port = "8888"
451471

452-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
472+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
473+
exe, args = ssh.FormatArgs(exe, args, needShell)
453474
assert.Equal(t, "sh", exe)
454475
assert.Equal(t, []string{"-c", plink + " -P 8888 [email protected]"}, args)
455476
}
@@ -465,7 +486,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCommand(t *testing.T) {
465486
meta := ssh.SSHMetadata{}
466487
meta.UserAndHost = "[email protected]"
467488

468-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
489+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
490+
exe, args = ssh.FormatArgs(exe, args, needShell)
469491
assert.Equal(t, "sh", exe)
470492
assert.Equal(t, []string{"-c", plink + " -batch [email protected]"}, args)
471493
}
@@ -482,7 +504,8 @@ func TestSSHGetExeAndArgsTortoisePlinkCommandCustomPort(t *testing.T) {
482504
meta.UserAndHost = "[email protected]"
483505
meta.Port = "8888"
484506

485-
exe, args := ssh.FormatArgs(ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, ""))
507+
exe, args, needShell, _, _ := ssh.GetExeAndArgs(cli.OSEnv(), cli.GitEnv(), &meta, false, "")
508+
exe, args = ssh.FormatArgs(exe, args, needShell)
486509
assert.Equal(t, "sh", exe)
487510
assert.Equal(t, []string{"-c", plink + " -batch -P 8888 [email protected]"}, args)
488511
}

0 commit comments

Comments
 (0)