aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-01-23 13:57:52 +0800
committerGitHub <noreply@github.com>2022-01-23 00:57:52 -0500
commit35fdefc1ff253522f101ffb1337437b59676c302 (patch)
tree56f3556eb1ed153af37fb2e965db073272307d94 /routers
parentf066b293accb8aed5809de87ae56140c90978d66 (diff)
downloadgitea-35fdefc1ff253522f101ffb1337437b59676c302.tar.gz
gitea-35fdefc1ff253522f101ffb1337437b59676c302.zip
Always use git command but not os.Command (#18363)
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/http.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go
index 3805ceea76..1b5004017f 100644
--- a/routers/web/repo/http.go
+++ b/routers/web/repo/http.go
@@ -12,7 +12,6 @@ import (
"fmt"
"net/http"
"os"
- "os/exec"
"path"
"regexp"
"strconv"
@@ -30,7 +29,6 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
- "code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
@@ -486,18 +484,17 @@ func serviceRPC(ctx gocontext.Context, h serviceHandler, service string) {
h.environ = append(h.environ, "GIT_PROTOCOL="+protocol)
}
- ctx, _, finished := process.GetManager().AddContext(h.r.Context(), fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir))
- defer finished()
-
var stderr bytes.Buffer
- cmd := exec.CommandContext(ctx, git.GitExecutable, service, "--stateless-rpc", h.dir)
- cmd.Dir = h.dir
- cmd.Env = append(os.Environ(), h.environ...)
- cmd.Stdout = h.w
- cmd.Stdin = reqBody
- cmd.Stderr = &stderr
-
- if err := cmd.Run(); err != nil {
+ cmd := git.NewCommandContextNoGlobals(h.r.Context(), service, "--stateless-rpc", h.dir)
+ cmd.SetDescription(fmt.Sprintf("%s %s %s [repo_path: %s]", git.GitExecutable, service, "--stateless-rpc", h.dir))
+ if err := cmd.RunWithContext(&git.RunContext{
+ Timeout: -1,
+ Dir: h.dir,
+ Env: append(os.Environ(), h.environ...),
+ Stdout: h.w,
+ Stdin: reqBody,
+ Stderr: &stderr,
+ }); err != nil {
log.Error("Fail to serve RPC(%s) in %s: %v - %s", service, h.dir, err, stderr.String())
return
}