Skip to content

Commit 234c2f6

Browse files
Add push SSH LFS protocol support
1 parent 621e1ff commit 234c2f6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/serv.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737

3838
const (
3939
lfsAuthenticateVerb = "git-lfs-authenticate"
40+
lfsTransferVerb = "git-lfs-transfer"
4041
)
4142

4243
// CmdServ represents the available serv sub-command.
@@ -78,6 +79,7 @@ var (
7879
"git-upload-archive": perm.AccessModeRead,
7980
"git-receive-pack": perm.AccessModeWrite,
8081
lfsAuthenticateVerb: perm.AccessModeNone,
82+
lfsTransferVerb: perm.AccessModeNone,
8183
}
8284
alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
8385
)
@@ -195,7 +197,7 @@ func runServ(c *cli.Context) error {
195197
}
196198

197199
var lfsVerb string
198-
if verb == lfsAuthenticateVerb {
200+
if verb == lfsAuthenticateVerb || verb == lfsTransferVerb {
199201
if !setting.LFS.StartServer {
200202
return fail(ctx, "Unknown git command", "LFS authentication request over SSH denied, LFS support is disabled")
201203
}
@@ -245,7 +247,7 @@ func runServ(c *cli.Context) error {
245247
return fail(ctx, "Unknown git command", "Unknown git command %s", verb)
246248
}
247249

248-
if verb == lfsAuthenticateVerb {
250+
if verb == lfsAuthenticateVerb || verb == lfsTransferVerb {
249251
if lfsVerb == "upload" {
250252
requestedMode = perm.AccessModeWrite
251253
} else if lfsVerb == "download" {
@@ -312,6 +314,9 @@ func runServ(c *cli.Context) error {
312314
// by default, use the verb (it has been checked above by allowedCommands)
313315
gitcmd = exec.CommandContext(ctx, gitBinVerb, repoPath)
314316
}
317+
if verb == lfsTransferVerb {
318+
gitcmd.Args = append(gitcmd.Args, lfsVerb)
319+
}
315320

316321
process.SetSysProcAttribute(gitcmd)
317322
gitcmd.Dir = setting.RepoRootPath

0 commit comments

Comments
 (0)