diff --git a/modules/git/git.go b/modules/git/git.go index 28899222e7efd..e70bf74dd1bc4 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -24,7 +24,7 @@ import ( ) // RequiredVersion is the minimum Git version required -const RequiredVersion = "2.0.0" +const RequiredVersion = "2.24.0" var ( // GitExecutable is the command name of git @@ -116,8 +116,7 @@ func VersionInfo() string { } format := "%s" args := []interface{}{gitVersion.Original()} - // Since git wire protocol has been released from git v2.18 - if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil { + if setting.Git.EnableAutoGitWireProtocol { format += ", Wire Protocol %s Enabled" args = append(args, "Version 2") // for focus color } diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index d3731cb928e30..6604fd02875a9 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -161,7 +161,7 @@ func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) ([]*Co // add previous arguments except for --grep and --all hashCmd.AddArguments(args...) // add keyword as - hashCmd.AddArguments(v) + hashCmd.AddArguments("--end-of-options", v) // search with given constraints for commit matching sha hash of v hashMatching, _, err := hashCmd.RunStdBytes(&RunOpts{Dir: repo.Path}) @@ -211,9 +211,11 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) ( }() go func() { stderr := strings.Builder{} - err := NewCommand(repo.Ctx, "rev-list", revision, + err := NewCommand(repo.Ctx, "rev-list", "--max-count="+strconv.Itoa(setting.Git.CommitsRangeSize*page), - "--skip="+strconv.Itoa(skip), "--", file). + "--skip="+strconv.Itoa(skip), + "--end-of-options", revision, + "--", file). Run(&RunOpts{ Dir: repo.Path, Stdout: stdoutWriter, diff --git a/modules/git/repo_stats.go b/modules/git/repo_stats.go index cb44c58cec7e5..5e2c1d5d74d11 100644 --- a/modules/git/repo_stats.go +++ b/modules/git/repo_stats.go @@ -65,7 +65,7 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) if len(branch) == 0 { args = append(args, "--branches=*") } else { - args = append(args, "--first-parent", branch) + args = append(args, "--first-parent", "--", branch) } stderr := new(strings.Builder)