1
0
Fork 0
forked from forgejo/forgejo

Lazy load object format with command line and don't do it in OpenRepository (#29712)

Most time, when invoking `git.OpenRepository`, `objectFormat` will not
be used, so it's a waste to invoke commandline to get the object format.
This PR make it a lazy operation, only invoke that when necessary.

(cherry picked from commit e84e5db6de0306d514b1f1a9657931fb7197a188)
This commit is contained in:
Lunny Xiao 2024-03-12 12:21:27 +08:00 committed by Earl Warren
parent e825d007b1
commit c9d9255244
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
15 changed files with 72 additions and 31 deletions

View file

@ -41,7 +41,10 @@ func (repo *Repository) RemoveReference(name string) error {
// ConvertToHash returns a Hash object from a potential ID string
func (repo *Repository) ConvertToGitID(commitID string) (ObjectID, error) {
objectFormat := repo.objectFormat
objectFormat, err := repo.GetObjectFormat()
if err != nil {
return nil, err
}
if len(commitID) == hash.HexSize && objectFormat.IsValid(commitID) {
ID, err := NewIDFromString(commitID)
if err == nil {