aboutsummaryrefslogtreecommitdiffstats
path: root/modules/indexer/code
diff options
context:
space:
mode:
authorAdam Majer <amajer@suse.de>2023-12-13 21:02:00 +0000
committerGitHub <noreply@github.com>2023-12-13 21:02:00 +0000
commitcbf923e87bca0f50c2c01a60ccf544b63c365e98 (patch)
tree9e2e66c688bdc0f740e1ae333847dfb33677c730 /modules/indexer/code
parent064f05204c0539d1f92895776dee7f626a628e3b (diff)
downloadgitea-cbf923e87bca0f50c2c01a60ccf544b63c365e98.tar.gz
gitea-cbf923e87bca0f50c2c01a60ccf544b63c365e98.zip
Abstract hash function usage (#28138)
Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
Diffstat (limited to 'modules/indexer/code')
-rw-r--r--modules/indexer/code/git.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/indexer/code/git.go b/modules/indexer/code/git.go
index e4686fa01f..76cd78e11e 100644
--- a/modules/indexer/code/git.go
+++ b/modules/indexer/code/git.go
@@ -62,8 +62,8 @@ func isIndexable(entry *git.TreeEntry) bool {
}
// parseGitLsTreeOutput parses the output of a `git ls-tree -r --full-name` command
-func parseGitLsTreeOutput(stdout []byte) ([]internal.FileUpdate, error) {
- entries, err := git.ParseTreeEntries(stdout)
+func parseGitLsTreeOutput(objectFormat git.ObjectFormat, stdout []byte) ([]internal.FileUpdate, error) {
+ entries, err := git.ParseTreeEntries(objectFormat, stdout)
if err != nil {
return nil, err
}
@@ -92,7 +92,11 @@ func genesisChanges(ctx context.Context, repo *repo_model.Repository, revision s
}
var err error
- changes.Updates, err = parseGitLsTreeOutput(stdout)
+ objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
+ if err != nil {
+ return nil, err
+ }
+ changes.Updates, err = parseGitLsTreeOutput(objectFormat, stdout)
return &changes, err
}
@@ -169,6 +173,11 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
if err != nil {
return nil, err
}
- changes.Updates, err = parseGitLsTreeOutput(lsTreeStdout)
+
+ objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
+ if err != nil {
+ return nil, err
+ }
+ changes.Updates, err = parseGitLsTreeOutput(objectFormat, lsTreeStdout)
return &changes, err
}