summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-05-26 17:50:06 +0800
committerGitHub <noreply@github.com>2019-05-26 17:50:06 +0800
commit063fa9915958215fe028f1bc97afdf9f6ca2aca2 (patch)
tree6d7240ac47443820b90a00106b8bda46b0d9581e /modules/setting
parent6c16febe4d0e66592cdf1af0c38101f463e230b7 (diff)
downloadgitea-063fa9915958215fe028f1bc97afdf9f6ca2aca2.tar.gz
gitea-063fa9915958215fe028f1bc97afdf9f6ca2aca2.zip
when git version >= 2.18, git command could run with git wire protocol version 2 param if enabled (#7047)
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/git.go37
1 files changed, 24 insertions, 13 deletions
diff --git a/modules/setting/git.go b/modules/setting/git.go
index 8625c0e780..673bff207e 100644
--- a/modules/setting/git.go
+++ b/modules/setting/git.go
@@ -16,12 +16,13 @@ import (
var (
// Git settings
Git = struct {
- DisableDiffHighlight bool
- MaxGitDiffLines int
- MaxGitDiffLineCharacters int
- MaxGitDiffFiles int
- GCArgs []string `delim:" "`
- Timeout struct {
+ DisableDiffHighlight bool
+ MaxGitDiffLines int
+ MaxGitDiffLineCharacters int
+ MaxGitDiffFiles int
+ GCArgs []string `delim:" "`
+ EnableAutoGitWireProtocol bool
+ Timeout struct {
Default int
Migrate int
Mirror int
@@ -30,11 +31,12 @@ var (
GC int `ini:"GC"`
} `ini:"git.timeout"`
}{
- DisableDiffHighlight: false,
- MaxGitDiffLines: 1000,
- MaxGitDiffLineCharacters: 5000,
- MaxGitDiffFiles: 100,
- GCArgs: []string{},
+ DisableDiffHighlight: false,
+ MaxGitDiffLines: 1000,
+ MaxGitDiffLineCharacters: 5000,
+ MaxGitDiffFiles: 100,
+ GCArgs: []string{},
+ EnableAutoGitWireProtocol: true,
Timeout: struct {
Default int
Migrate int
@@ -64,10 +66,19 @@ func newGit() {
log.Fatal("Error retrieving git version: %v", err)
}
- log.Info("Git Version: %s", binVersion)
-
if version.Compare(binVersion, "2.9", ">=") {
// Explicitly disable credential helper, otherwise Git credentials might leak
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
}
+
+ var format = "Git Version: %s"
+ var args = []interface{}{binVersion}
+ // Since git wire protocol has been released from git v2.18
+ if Git.EnableAutoGitWireProtocol && version.Compare(binVersion, "2.18", ">=") {
+ git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "protocol.version=2")
+ format += ", Wire Protocol %s Enabled"
+ args = append(args, "Version 2") // for focus color
+ }
+
+ log.Info(format, args...)
}