mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 04:41:33 +00:00 
			
		
		
		
	On open repository open common cat file batch and batch-check (#15667)
Use common git cat-file --batch and git cat-file --batch-check to
significantly reduce calls to git.
    
Signed-off-by: Andrew Thornton <art27@cantab.net>
			
			
This commit is contained in:
		| @@ -102,7 +102,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache *LastCo | ||||
| } | ||||
|  | ||||
| func getLastCommitForPathsByCache(commitID, treePath string, paths []string, cache *LastCommitCache) (map[string]*Commit, []string, error) { | ||||
| 	wr, rd, cancel := CatFileBatch(cache.repo.Path) | ||||
| 	wr, rd, cancel := cache.repo.CatFileBatch() | ||||
| 	defer cancel() | ||||
|  | ||||
| 	var unHitEntryPaths []string | ||||
| @@ -144,7 +144,7 @@ func GetLastCommitForPaths(commit *Commit, treePath string, paths []string) ([]* | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	batchStdinWriter, batchReader, cancel := CatFileBatch(commit.repo.Path) | ||||
| 	batchStdinWriter, batchReader, cancel := commit.repo.CatFileBatch() | ||||
| 	defer cancel() | ||||
|  | ||||
| 	mapsize := 4096 | ||||
| @@ -237,6 +237,10 @@ revListLoop: | ||||
| 					// FIXME: is there any order to the way strings are emitted from cat-file? | ||||
| 					// if there is - then we could skip once we've passed all of our data | ||||
| 				} | ||||
| 				if _, err := batchReader.Discard(1); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
|  | ||||
| 				break treeReadingLoop | ||||
| 			} | ||||
|  | ||||
| @@ -281,6 +285,9 @@ revListLoop: | ||||
| 					return nil, err | ||||
| 				} | ||||
| 			} | ||||
| 			if _, err := batchReader.Discard(1); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			// if we haven't found a treeID for the target directory our search is over | ||||
| 			if len(treeID) == 0 { | ||||
| @@ -345,6 +352,9 @@ revListLoop: | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if _, err := batchReader.Discard(1); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		commitCommits[i] = c | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user