aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/commit_info_nogogit.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-08-21 01:04:57 +0800
committerGitHub <noreply@github.com>2024-08-20 17:04:57 +0000
commitc03baab678ba5b2e9d974aea147e660417f5d3f7 (patch)
tree2b890d549a150cc1c9f6101218789601f40b960f /modules/git/commit_info_nogogit.go
parent8b92eba21f5c5cca277b8101ada0ea7a1fb32ae0 (diff)
downloadgitea-c03baab678ba5b2e9d974aea147e660417f5d3f7.tar.gz
gitea-c03baab678ba5b2e9d974aea147e660417f5d3f7.zip
Refactor the usage of batch catfile (#31754)
When opening a repository, it will call `ensureValidRepository` and also `CatFileBatch`. But sometimes these will not be used until repository closed. So it's a waste of CPU to invoke 3 times git command for every open repository. This PR removed all of these from `OpenRepository` but only kept checking whether the folder exists. When a batch is necessary, the necessary functions will be invoked.
Diffstat (limited to 'modules/git/commit_info_nogogit.go')
-rw-r--r--modules/git/commit_info_nogogit.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/git/commit_info_nogogit.go b/modules/git/commit_info_nogogit.go
index 7c369b07f9..cfde64a033 100644
--- a/modules/git/commit_info_nogogit.go
+++ b/modules/git/commit_info_nogogit.go
@@ -124,7 +124,10 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string,
return nil, err
}
- batchStdinWriter, batchReader, cancel := commit.repo.CatFileBatch(ctx)
+ batchStdinWriter, batchReader, cancel, err := commit.repo.CatFileBatch(ctx)
+ if err != nil {
+ return nil, err
+ }
defer cancel()
commitsMap := map[string]*Commit{}