MCPcopy
hub / github.com/go-git/go-git / Write

Method Write

plumbing/format/objfile/writer.go:73–92  ·  view source on GitHub ↗

Write writes the object's contents. Write returns the error ErrOverflow if more than size bytes are written after WriteHeader.

(p []byte)

Source from the content-addressed store, hash-verified

71// Write writes the object's contents. Write returns the error ErrOverflow if
72// more than size bytes are written after WriteHeader.
73func (w *Writer) Write(p []byte) (n int, err error) {
74 if w.closed {
75 return 0, ErrClosed
76 }
77
78 overwrite := false
79 if int64(len(p)) > w.pending {
80 p = p[0:w.pending]
81 overwrite = true
82 }
83
84 n, err = w.multi.Write(p)
85 w.pending -= int64(n)
86 if err == nil && overwrite {
87 err = ErrOverflow
88 return
89 }
90
91 return
92}
93
94// Hash returns the hash of the object data stream that has been written so far.
95// It can be called before or after Close.

Callers 15

zlibCompressFunction · 0.95
TestWriteOverflowMethod · 0.95
finishMethod · 0.45
TestSha1CollisionFunction · 0.45
SetUpTestMethod · 0.45
EncodeMethod · 0.45

Calls

no outgoing calls

Tested by 15

zlibCompressFunction · 0.76
TestWriteOverflowMethod · 0.76
TestSha1CollisionFunction · 0.36
SetUpTestMethod · 0.36
TestDecodeV4StripLengthFunction · 0.36