Move catfile batch to a sub package of git module (#36232)

This commit is contained in:
Lunny Xiao
2025-12-29 10:19:42 -08:00
committed by GitHub
parent d0cb198c89
commit 0ad94dfc70
17 changed files with 500 additions and 412 deletions
+6 -5
View File
@@ -26,12 +26,13 @@ type Blob struct {
// DataAsync gets a ReadCloser for the contents of a blob without reading it all.
// Calling the Close function on the result will discard all unread output.
func (b *Blob) DataAsync() (io.ReadCloser, error) {
wr, rd, cancel, err := b.repo.CatFileBatch(b.repo.Ctx)
batch, cancel, err := b.repo.CatFileBatch(b.repo.Ctx)
if err != nil {
return nil, err
}
_, err = wr.Write([]byte(b.ID.String() + "\n"))
rd := batch.Reader()
_, err = batch.Writer().Write([]byte(b.ID.String() + "\n"))
if err != nil {
cancel()
return nil, err
@@ -67,18 +68,18 @@ func (b *Blob) Size() int64 {
return b.size
}
wr, rd, cancel, err := b.repo.CatFileBatchCheck(b.repo.Ctx)
batch, cancel, err := b.repo.CatFileBatchCheck(b.repo.Ctx)
if err != nil {
log.Debug("error whilst reading size for %s in %s. Error: %v", b.ID.String(), b.repo.Path, err)
return 0
}
defer cancel()
_, err = wr.Write([]byte(b.ID.String() + "\n"))
_, err = batch.Writer().Write([]byte(b.ID.String() + "\n"))
if err != nil {
log.Debug("error whilst reading size for %s in %s. Error: %v", b.ID.String(), b.repo.Path, err)
return 0
}
_, _, b.size, err = ReadBatchLine(rd)
_, _, b.size, err = ReadBatchLine(batch.Reader())
if err != nil {
log.Debug("error whilst reading size for %s in %s. Error: %v", b.ID.String(), b.repo.Path, err)
return 0