Encode creates a packfile containing all the objects referenced in hashes and writes it to the writer in the Encoder. `packWindow` specifies the size of the sliding window used to compare objects for delta compression; 0 turns off delta compression entirely.
( hashes []plumbing.Hash, packWindow uint, )
| 47 | // specifies the size of the sliding window used to compare objects |
| 48 | // for delta compression; 0 turns off delta compression entirely. |
| 49 | func (e *Encoder) Encode( |
| 50 | hashes []plumbing.Hash, |
| 51 | packWindow uint, |
| 52 | ) (plumbing.Hash, error) { |
| 53 | objects, err := e.selector.ObjectsToPack(hashes, packWindow) |
| 54 | if err != nil { |
| 55 | return plumbing.ZeroHash, err |
| 56 | } |
| 57 | |
| 58 | return e.encode(objects) |
| 59 | } |
| 60 | |
| 61 | func (e *Encoder) encode(objects []*ObjectToPack) (plumbing.Hash, error) { |
| 62 | if err := e.head(len(objects)); err != nil { |