mirror of https://github.com/go-gitea/gitea.git
when git version >= 2.18, git command could run with git wire protocol version 2 param if enabled (#7047)
This commit is contained in:
parent
6c16febe4d
commit
063fa99159
|
@ -671,6 +671,8 @@ MAX_GIT_DIFF_FILES = 100
|
||||||
; Arguments for command 'git gc', e.g. "--aggressive --auto"
|
; Arguments for command 'git gc', e.g. "--aggressive --auto"
|
||||||
; see more on http://git-scm.com/docs/git-gc/
|
; see more on http://git-scm.com/docs/git-gc/
|
||||||
GC_ARGS =
|
GC_ARGS =
|
||||||
|
; If use git wire protocol version 2 when git version >= 2.18, default is true, set to false when you always want git wire protocol version 1
|
||||||
|
EnableAutoGitWireProtocol = true
|
||||||
|
|
||||||
; Operation timeout in seconds
|
; Operation timeout in seconds
|
||||||
[git.timeout]
|
[git.timeout]
|
||||||
|
|
|
@ -396,6 +396,7 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false`
|
||||||
- `MAX_GIT_DIFF_LINE_CHARACTERS`: **5000**: Max character count per line highlighted in diff view.
|
- `MAX_GIT_DIFF_LINE_CHARACTERS`: **5000**: Max character count per line highlighted in diff view.
|
||||||
- `MAX_GIT_DIFF_FILES`: **100**: Max number of files shown in diff view.
|
- `MAX_GIT_DIFF_FILES`: **100**: Max number of files shown in diff view.
|
||||||
- `GC_ARGS`: **\<empty\>**: Arguments for command `git gc`, e.g. `--aggressive --auto`. See more on http://git-scm.com/docs/git-gc/
|
- `GC_ARGS`: **\<empty\>**: Arguments for command `git gc`, e.g. `--aggressive --auto`. See more on http://git-scm.com/docs/git-gc/
|
||||||
|
- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: If use git wire protocol version 2 when git version >= 2.18, default is true, set to false when you always want git wire protocol version 1
|
||||||
|
|
||||||
## Git - Timeout settings (`git.timeout`)
|
## Git - Timeout settings (`git.timeout`)
|
||||||
- `DEFAUlT`: **360**: Git operations default timeout seconds.
|
- `DEFAUlT`: **360**: Git operations default timeout seconds.
|
||||||
|
|
|
@ -210,6 +210,7 @@ menu:
|
||||||
- `CLONE`: **300**: 内部仓库间克隆的超时时间,单位秒
|
- `CLONE`: **300**: 内部仓库间克隆的超时时间,单位秒
|
||||||
- `PULL`: **300**: 内部仓库间拉取的超时时间,单位秒
|
- `PULL`: **300**: 内部仓库间拉取的超时时间,单位秒
|
||||||
- `GC`: **60**: git仓库GC的超时时间,单位秒
|
- `GC`: **60**: git仓库GC的超时时间,单位秒
|
||||||
|
- `ENABLE_AUTO_GIT_WIRE_PROTOCOL`: **true**: 是否根据 Git Wire Protocol协议支持情况自动切换版本,当 git 版本在 2.18 及以上时会自动切换到版本2。为 `false` 则不切换。
|
||||||
|
|
||||||
## API (`api`)
|
## API (`api`)
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,13 @@ import (
|
||||||
var (
|
var (
|
||||||
// Git settings
|
// Git settings
|
||||||
Git = struct {
|
Git = struct {
|
||||||
DisableDiffHighlight bool
|
DisableDiffHighlight bool
|
||||||
MaxGitDiffLines int
|
MaxGitDiffLines int
|
||||||
MaxGitDiffLineCharacters int
|
MaxGitDiffLineCharacters int
|
||||||
MaxGitDiffFiles int
|
MaxGitDiffFiles int
|
||||||
GCArgs []string `delim:" "`
|
GCArgs []string `delim:" "`
|
||||||
Timeout struct {
|
EnableAutoGitWireProtocol bool
|
||||||
|
Timeout struct {
|
||||||
Default int
|
Default int
|
||||||
Migrate int
|
Migrate int
|
||||||
Mirror int
|
Mirror int
|
||||||
|
@ -30,11 +31,12 @@ var (
|
||||||
GC int `ini:"GC"`
|
GC int `ini:"GC"`
|
||||||
} `ini:"git.timeout"`
|
} `ini:"git.timeout"`
|
||||||
}{
|
}{
|
||||||
DisableDiffHighlight: false,
|
DisableDiffHighlight: false,
|
||||||
MaxGitDiffLines: 1000,
|
MaxGitDiffLines: 1000,
|
||||||
MaxGitDiffLineCharacters: 5000,
|
MaxGitDiffLineCharacters: 5000,
|
||||||
MaxGitDiffFiles: 100,
|
MaxGitDiffFiles: 100,
|
||||||
GCArgs: []string{},
|
GCArgs: []string{},
|
||||||
|
EnableAutoGitWireProtocol: true,
|
||||||
Timeout: struct {
|
Timeout: struct {
|
||||||
Default int
|
Default int
|
||||||
Migrate int
|
Migrate int
|
||||||
|
@ -64,10 +66,19 @@ func newGit() {
|
||||||
log.Fatal("Error retrieving git version: %v", err)
|
log.Fatal("Error retrieving git version: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Git Version: %s", binVersion)
|
|
||||||
|
|
||||||
if version.Compare(binVersion, "2.9", ">=") {
|
if version.Compare(binVersion, "2.9", ">=") {
|
||||||
// Explicitly disable credential helper, otherwise Git credentials might leak
|
// Explicitly disable credential helper, otherwise Git credentials might leak
|
||||||
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
|
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...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue