aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-01 18:53:41 -0500
committerGitHub <noreply@github.com>2023-03-02 01:53:41 +0200
commit39178b57561110737a54c8ba52d5e96640804df8 (patch)
tree99bcbd21c193413592fa000f9b66eff355b49bcd
parent3d8412dd51760fd715be7650f5bdc81228f6ba87 (diff)
downloadgitea-39178b57561110737a54c8ba52d5e96640804df8.tar.gz
gitea-39178b57561110737a54c8ba52d5e96640804df8.zip
Do not create commit graph for temporary repos (#23219) (#23229)
Backport #23219 When fetching remotes for conflict checking, skip unnecessary and potentially slow writing of commit graphs. In a test with the Blender repository, this reduces conflict checking time for one pull request from about 2s to 0.1s. Co-authored-by: Brecht Van Lommel <brecht@blender.org>
-rw-r--r--services/pull/temp_repo.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go
index e0d6b4a158..2bef671555 100644
--- a/services/pull/temp_repo.go
+++ b/services/pull/temp_repo.go
@@ -67,6 +67,12 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
remoteRepoName := "head_repo"
baseBranch := "base"
+ fetchArgs := git.TrustedCmdArgs{"--no-tags"}
+ if git.CheckGitVersionAtLeast("2.25.0") == nil {
+ // Writing the commit graph can be slow and is not needed here
+ fetchArgs = append(fetchArgs, "--no-write-commit-graph")
+ }
+
// Add head repo remote.
addCacheRepo := func(staging, cache string) error {
p := filepath.Join(staging, ".git", "objects", "info", "alternates")
@@ -108,7 +114,7 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
outbuf.Reset()
errbuf.Reset()
- if err := git.NewCommand(ctx, "fetch", "origin", "--no-tags").AddDashesAndList(pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).
+ if err := git.NewCommand(ctx, "fetch", "origin").AddArguments(fetchArgs...).AddDashesAndList(pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).
Run(&git.RunOpts{
Dir: tmpBasePath,
Stdout: &outbuf,
@@ -171,7 +177,7 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
} else {
headBranch = pr.GetGitRefName()
}
- if err := git.NewCommand(ctx, "fetch", "--no-tags").AddDynamicArguments(remoteRepoName, headBranch+":"+trackingBranch).
+ if err := git.NewCommand(ctx, "fetch").AddArguments(fetchArgs...).AddDynamicArguments(remoteRepoName, headBranch+":"+trackingBranch).
Run(&git.RunOpts{
Dir: tmpBasePath,
Stdout: &outbuf,