Documentation ¶
Overview ¶
Package advrefs implements encoding and decoding advertised-refs messages from a git-upload-pack command.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = errors.New("empty advertised-ref message")
ErrEmpty is returned by Decode when there was no advertised-message at all
Functions ¶
This section is empty.
Types ¶
type AdvRefs ¶
type AdvRefs struct { Prefix [][]byte // payloads of the prefix Head *core.Hash Capabilities *packp.Capabilities References map[string]core.Hash Peeled map[string]core.Hash Shallows []core.Hash }
AdvRefs values represent the information transmitted on an advertised-refs message. Values from this type are not zero-value safe, use the New function instead.
When using this messages over (smart) HTTP, you have to add a pktline before the whole thing with the following payload:
'# service=$servicename" LF
Moreover, some (all) git HTTP smart servers will send a flush-pkt just after the first pkt-line.
To accomodate both situations, the Prefix field allow you to store any data you want to send before the actual pktlines. It will also be filled up with whatever is found on the line.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes AdvRef values from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
Will not read more data from r than necessary.
func (*Decoder) Decode ¶
Decode reads the next advertised-refs message form its input and stores it in the value pointed to by v.
Example ¶
Output: head = a6930aaee06755d1bdcfd943fbf614e4d92bb0c7 capabilities = multi_ack ofs-delta symref=HEAD:/refs/heads/master ... shallows = [5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c]
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes AdvRefs values to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
func (*Encoder) Encode ¶
Encode writes the AdvRefs encoding of v to the stream.
All the payloads will end with a newline character. Capabilities, references and shallows are writen in alphabetical order, except for peeled references that always follow their corresponding references.
Example ¶
Output: "00651111111111111111111111111111111111111111 HEAD\x00multi_ack ofs-delta symref=HEAD:/refs/heads/master\n003f2222222222222222222222222222222222222222 refs/heads/master\n003a3333333333333333333333333333333333333333 refs/tags/v1\n003d4444444444444444444444444444444444444444 refs/tags/v1^{}\n0035shallow 5555555555555555555555555555555555555555\n0000"