Skip to content

Commit 1da989e

Browse files
author
Axel Wagner
committed
Add Write(w io.Writer) to packbuilder
This wraps (*packbuilder).ForEach(), making it possible to write the pack easiliy to a tcp-connection, a HTTP-Body or the like.
1 parent 140f362 commit 1da989e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packbuilder.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ func (pb *Packbuilder) WriteToFile(name string) error {
7474
return nil
7575
}
7676

77+
func (pb *Packbuilder) Write(w io.Writer) error {
78+
ch := pb.Foreach()
79+
for _, slice := range ch {
80+
_, err := w.Write(slice)
81+
if err != nil {
82+
return err
83+
}
84+
}
85+
return nil
86+
}
87+
7788
func (pb *Packbuilder) Written() uint32 {
7889
return uint32(C.git_packbuilder_written(pb.ptr))
7990
}

0 commit comments

Comments
 (0)