packp

package
v6.0.0-alpha.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Overview

Package packp implements encoding and decoding of the Git packfile protocol messages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyAdvRefs is returned by Decode if it gets an empty advertised
	// references message.
	ErrEmptyAdvRefs = errors.New("empty advertised-ref message")
	// ErrEmptyInput is returned by Decode if the input is empty.
	ErrEmptyInput = errors.New("empty input")
)
View Source
var (
	ErrEmptyCommands    = errors.New("commands cannot be empty")
	ErrMalformedCommand = errors.New("malformed command")
)

Errors returned by the updreq package.

View Source
var ErrDeepenMutuallyExclusive = errors.New("deepen and deepen-since (or deepen-not) cannot be used together")

ErrDeepenMutuallyExclusive is returned when a request contains both deepen and deepen-since/deepen-not specifications.

View Source
var (
	ErrEmpty = errors.New("empty update-request message")
)

Decode errors.

View Source
var ErrInvalidGitProtoRequest = fmt.Errorf("invalid git protocol request")

ErrInvalidGitProtoRequest is returned by Decode if the input is not a valid git protocol request.

View Source
var ErrInvalidPushOption = errors.New("invalid push option")

ErrInvalidPushOption is returned when a push option contains invalid characters.

View Source
var ErrInvalidSmartReply = errors.New("invalid smart reply")

ErrInvalidSmartReply is returned when a SmartReply is invalid.

View Source
var ErrNilWriter = fmt.Errorf("nil writer")

ErrNilWriter is returned when a nil writer is passed to the encoder.

View Source
var ErrUnsupportedObjectFilterType = errors.New("unsupported object filter type")

ErrUnsupportedObjectFilterType is returned when the filter type is not supported.

Functions

func DecodeListV2

func DecodeListV2(r io.Reader, l *capability.List) (int, error)

DecodeListV2 reads capabilities in v2 format from a pkt-line stream. It reads pkt-lines until flush-pkt, delim-pkt, or EOF, appending each parsed capability to the list. It returns the terminating packet length (pktline.Flush, pktline.Delim, or pktline.ResponseEnd) so the caller knows what terminated the capability list.

func EncodeListV2

func EncodeListV2(w io.Writer, l *capability.List) error

EncodeListV2 writes capabilities in v2 format: one capability per pkt-line. Each capability is written as "key\n" or "key=value\n" or "key=v1 v2\n". The caller is responsible for writing the terminating packet (flush-pkt or delim-pkt) after the last capability.

func NewErrUnexpectedData

func NewErrUnexpectedData(msg string, data []byte) error

NewErrUnexpectedData returns a new ErrUnexpectedData containing the data and the message given

func ResolveHeadFromHashHeuristic

func ResolveHeadFromHashHeuristic(head *plumbing.Reference, refs []*plumbing.Reference) *plumbing.Reference

ResolveHeadFromHashHeuristic converts a detached HEAD (a HashReference) into a SymbolicReference pointing to the branch that shares its hash, scanning refs. It is shared by the v0/v1 advertisement resolution and the Protocol v2 ls-refs path, so a detached remote HEAD still yields a symbolic local HEAD on clone, matching reference git's pre-symref heuristic:

  • Prefer refs/heads/master when it has the same hash as HEAD.
  • Otherwise pick the alphabetically-first non-peeled ref with that hash.
  • If nothing matches, HEAD is returned unchanged.

Types

type ACK

type ACK struct {
	Hash   plumbing.Hash
	Status ACKStatus
}

ACK represents an object acknowledgement. A status can be zero when the response doesn't support multi_ack and multi_ack_detailed capabilities.

type ACKStatus

type ACKStatus byte

ACKStatus represents the status of an object acknowledgement.

const (
	ACKContinue ACKStatus = iota + 1
	ACKCommon
	ACKReady
)

ACKStatus values

func (ACKStatus) String

func (s ACKStatus) String() string

String returns the string representation of the ACKStatus.

type Acknowledgments

type Acknowledgments struct {
	// ACKs is the list of common object IDs acknowledged by the server.
	// Empty list means the server found no common objects (NAK).
	ACKs []plumbing.Hash
	// Ready indicates the server is ready to send a packfile after the
	// acknowledgments section. For stream transports, ready is implied and
	// this field is always true.
	Ready bool
}

Acknowledgments represents the server response to a v2 fetch command's acknowledgments section. It is used by the transport layer to determine which objects the server has in common with the client.

type Action

type Action string

Action represents the action type of a command.

const (
	Create  Action = "create"
	Update  Action = "update"
	Delete  Action = "delete"
	Invalid Action = "invalid"
)

Action types.

type AdvRefs

type AdvRefs struct {
	// Version is the protocol version of the advertisement. The only acceptable
	// values are V0 and V1; any other value is invalid. Decode parses it from
	// the leading "version" pkt-line (absent for V0) and Encode emits that line
	// from it. Within the transport it is set from the version the handshake
	// negotiated (DiscoverVersion), which is the single source of truth.
	Version protocol.Version
	// Capabilities are the capabilities.
	Capabilities capability.List
	// References are the hash references, including HEAD and peeled refs
	// (whose names end in ^{}). They are stored in wire order.
	References []*plumbing.Reference
	// Shallows are the shallow object ids.
	Shallows []plumbing.Hash
}

AdvRefs values represent the information transmitted on an advertised-refs message. The zero value is safe to use; References and Shallows can be populated via append.

func (*AdvRefs) Decode

func (a *AdvRefs) Decode(r io.Reader) error

Decode reads the next advertised-refs message form its input and stores it in the AdvRefs.

func (*AdvRefs) Encode

func (a *AdvRefs) Encode(w io.Writer) error

Encode writes the AdvRefs encoding to a writer.

All the payloads will end with a newline character. Capabilities, references and shallows are written in alphabetical order, except for peeled references that always follow their corresponding references.

func (*AdvRefs) Head

func (a *AdvRefs) Head() (*plumbing.Reference, error)

Head returns the HEAD reference. It checks the first reference in References (HEAD is always first on the wire) before scanning the rest.

func (*AdvRefs) IsEmpty

func (a *AdvRefs) IsEmpty() bool

IsEmpty returns true if doesn't contain any reference.

func (*AdvRefs) ResolvedHead

func (a *AdvRefs) ResolvedHead() (*plumbing.Reference, error)

ResolvedHead returns HEAD as a SymbolicReference when possible. If the symref capability is present it is used; otherwise the heuristic described in resolvedHeadFromHeuristic is applied. If HEAD cannot be resolved it is returned as-is (a HashReference). Returns ErrReferenceNotFound if HEAD is not present in References.

func (*AdvRefs) ResolvedReferences

func (a *AdvRefs) ResolvedReferences() ([]*plumbing.Reference, error)

ResolvedReferences returns all references with HEAD resolved to a SymbolicReference when possible, and symref capabilities applied to other references. The result is sorted by reference name.

type BlobLimitPrefix

type BlobLimitPrefix string

BlobLimitPrefix specifies the unit prefix for blob size limits.

const (
	BlobLimitPrefixNone BlobLimitPrefix = ""
	BlobLimitPrefixKibi BlobLimitPrefix = "k"
	BlobLimitPrefixMebi BlobLimitPrefix = "m"
	BlobLimitPrefixGibi BlobLimitPrefix = "g"
)

Blob limit prefix values.

type CapabilityAdv

type CapabilityAdv struct {
	// Version is the protocol version. Decode sets this to V2.
	// Encode writes the version line when Version is V2.
	Version protocol.Version
	// Capabilities is the parsed list of server capabilities.
	Capabilities capability.List
}

CapabilityAdv represents a protocol v2 server capability advertisement. It includes the version line and the capability lines that follow it.

In protocol v2, the server sends:

version 2\n
agent=git/2.45.0\n
ls-refs=unborn\n
fetch=shallow wait-for-done filter\n
0000

Capabilities are one per line in "key" or "key=value" format, terminated by a flush packet. This differs from v0/v1 where capabilities are space-separated after a NUL byte on the first ref line.

func (*CapabilityAdv) Decode

func (ca *CapabilityAdv) Decode(r io.Reader) error

Decode reads a v2 capability advertisement from a pkt-line stream. It expects the stream to start with the "version 2\n" line, followed by capability lines (one per line), terminated by a flush packet.

func (*CapabilityAdv) Encode

func (ca *CapabilityAdv) Encode(w io.Writer) error

Encode writes a v2 capability advertisement to a pkt-line stream. It writes the "version N\n" line (where N is ca.Version), then each capability on its own line, and terminates with a flush packet. Encode returns an error if ca.Version is not V2.

type Command

type Command struct {
	Name plumbing.ReferenceName
	Old  plumbing.Hash
	New  plumbing.Hash
}

Command represents a command to be executed on a reference.

func (*Command) Action

func (c *Command) Action() Action

Action returns the action type of the command.

type CommandArgs

type CommandArgs interface {
	Encoder
	Decoder
}

CommandArgs is the interface for v2 command-specific arguments.

type CommandRequest

type CommandRequest struct {
	Command      string
	Capabilities capability.List
	Args         CommandArgs
}

CommandRequest represents a v2 command request.

Wire format:

request = empty-request | command-request
empty-request = flush-pkt
command-request = command
    capability-list
    delim-pkt
    command-args
    flush-pkt
command = PKT-LINE("command=" key LF)
command-args = *command-specific-arg

An empty Command encodes as an empty request (a single flush-pkt). On decode, a flush-pkt as the first packet leaves Command empty.

func (*CommandRequest) Decode

func (c *CommandRequest) Decode(r io.Reader) error

Decode reads a command request from r. If the first packet is a flush-pkt, Command is left empty (empty request).

func (*CommandRequest) Encode

func (c *CommandRequest) Encode(w io.Writer) error

Encode writes the command request to w. If Command is empty, it writes a single flush-pkt (empty request).

type CommandStatus

type CommandStatus struct {
	ReferenceName plumbing.ReferenceName
	Status        string
}

CommandStatus is the status of a reference in a report status. See ReportStatus struct.

func (*CommandStatus) Error

func (s *CommandStatus) Error() error

Error returns the error, if any.

type CommandStatusErr

type CommandStatusErr struct {
	ReferenceName plumbing.ReferenceName
	Status        string
}

CommandStatusErr is the error returned when the command status is not ok.

func (CommandStatusErr) Error

func (e CommandStatusErr) Error() string

Error implements the error interface.

type Decoder

type Decoder interface {
	Decode(r io.Reader) error
}

Decoder is the interface implemented by an object that can decode itself from a io.Reader.

type DepthRequest

type DepthRequest struct {
	// Deepen limits the fetch to the given number of commits from the tip.
	// Zero means no commit-based depth limit.
	// Corresponds to "deepen <n>" in the protocol.
	Deepen int

	// DeepenSince limits the fetch to commits newer than the given time.
	// Zero value means no time-based limit.
	// Corresponds to "deepen-since <timestamp>" in the protocol.
	DeepenSince time.Time

	// DeepenNot excludes commits reachable from the named references.
	// Multiple refs may be specified. Each emits a "deepen-not <ref>" line.
	DeepenNot []string
}

DepthRequest specifies the depth constraints for a fetch request. The zero value means no depth constraint (infinite depth).

Commits cannot be combined with Since or NotRefs (git rejects it). Since and NotRefs may be combined to further refine the shallow boundary.

func (DepthRequest) IsZero

func (d DepthRequest) IsZero() bool

IsZero returns true when no depth constraints are set.

type Encoder

type Encoder interface {
	Encode(w io.Writer) error
}

Encoder is the interface implemented by an object that can encode itself into a io.Writer.

type ErrUnexpectedData

type ErrUnexpectedData struct {
	Msg  string
	Data []byte
}

ErrUnexpectedData represents an unexpected data decoding a message

func (*ErrUnexpectedData) Error

func (err *ErrUnexpectedData) Error() string

type FetchArgs

type FetchArgs struct {
	// Wants is the list of object IDs the client wants.
	Wants []plumbing.Hash
	// Haves is the list of object IDs the client already has.
	Haves []plumbing.Hash
	// Done indicates the client is done sending wants and haves.
	// If false, the client may send additional want/have lines
	// in subsequent request rounds (stateful transport only).
	Done bool
	// ThinPack requests a thin pack if the server supports it.
	ThinPack bool
	// NoProgress requests that the server suppress progress messages.
	NoProgress bool
	// IncludeTag requests that the server include tag objects.
	IncludeTag bool
	// OFSDelta requests that the server use OFS_DELTA objects.
	OFSDelta bool
	// Shallows is the list of shallow object IDs the client has.
	Shallows []plumbing.Hash
	// Deepen specifies the number of depth commits to fetch.
	Deepen int
	// DeepenRelative indicates that deepen is relative to the shallow boundary.
	DeepenRelative bool
	// DeepenSince specifies a time-based depth constraint.
	DeepenSince time.Time
	// DeepenNot specifies references to exclude from the shallow boundary.
	DeepenNot []string

	// Filter specifies a partial clone filter.
	Filter Filter
	// WaitForDone indicates that the client will wait for the server to send a
	// done acknowledgment before sending additional want/have lines.
	WaitForDone bool
}

FetchArgs represents the arguments for the v2 fetch command.

func (*FetchArgs) Decode

func (r *FetchArgs) Decode(rd io.Reader) error

Decode reads v2 fetch command arguments from a reader until a flush-pkt is encountered. The caller is responsible for reading the delim-pkt and command header before calling Decode.

func (*FetchArgs) Encode

func (r *FetchArgs) Encode(w io.Writer) error

Encode writes the v2 fetch command arguments to a writer. Each argument is written as a separate pkt-line. The caller is responsible for writing the delim-pkt before and the flush-pkt after these arguments.

type FetchOutput

type FetchOutput struct {
	// Acknowledgments indicates the server sent an acknowledgments section.
	Acknowledgments *Acknowledgments
	// ShallowInfo indicates the server sent a shallow-info section.
	ShallowInfo *ShallowInfo
	// WantedRefs indicates the server sent a wanted-refs section.
	WantedRefs *WantedRefs
	// PackfileURIs indicates the server sent a packfile-uris section.
	PackfileURIs *PackfileURIs
	// Packfile reports whether a packfile section follows the metadata
	// sections. When true, Decode leaves the reader positioned at the first
	// packfile pkt-line so the caller can stream it, and Encode writes the
	// "packfile" section header so the caller can write the packfile data.
	// When false, the response is a negotiation round
	// (acknowledgments flush-pkt) that carries no packfile.
	Packfile bool
}

FetchOutput represents the server response to a v2 fetch command.

The response has explicit sections separated by delim-pkt:

acknowledgments\n
ACK <oid>\n
ready\n
0001
shallow-info\n
shallow <oid>\n
0001
packfile\n
<sideband packfile data>
0000

For HTTP, the transport layer consumes response-end (0002) after Decode returns.

func (*FetchOutput) Decode

func (r *FetchOutput) Decode(rd io.Reader) error

Decode reads the v2 fetch response from a reader. The response has explicit sections separated by delim-pkt:

acknowledgments\n
ACK <oid>\n
ready\n
0001
shallow-info\n
shallow <oid>\n
0001
packfile\n
<sideband packfile data>
0000

A response is one of two shapes (gitprotocol-v2):

output = acknowledgments flush-pkt |
         [acknowledgments delim-pkt] [shallow-info delim-pkt]
         [wanted-refs delim-pkt] [packfile-uris delim-pkt]
         packfile flush-pkt

When a metadata section ends with a flush-pkt (the first shape) the response is a negotiation round that carries no packfile, and Decode returns with Packfile set to false. When Decode reaches the "packfile" section header it sets Packfile to true and returns with the reader positioned at the first packfile pkt-line; Decode does not read the packfile data, leaving the caller to stream it (demultiplexing the sideband as needed).

For HTTP, the transport layer consumes response-end (0002) after Decode returns.

func (*FetchOutput) Encode

func (r *FetchOutput) Encode(w io.Writer) error

Encode writes the v2 fetch response to a writer.

When Packfile is true, Encode writes the present metadata sections (acknowledgments, shallow-info, wanted-refs, packfile-uris), each terminated by a delim-pkt, followed by the "packfile" section header. The caller then streams the packfile data and writes the final flush-pkt.

When Packfile is false, the response is a negotiation round: Encode writes the acknowledgments section terminated by a flush-pkt and writes nothing else. In that case the acknowledgments section must be present and must not be ready, and no other metadata sections may be set.

type Filter

type Filter string

Filter values enable the partial clone capability which causes the server to omit objects that match the filter.

See Git's documentation for more details.

func FilterBlobLimit

func FilterBlobLimit(n uint64, prefix BlobLimitPrefix) Filter

FilterBlobLimit omits blobs of size at least n bytes (when prefix is BlobLimitPrefixNone), n kibibytes (when prefix is BlobLimitPrefixKibi), n mebibytes (when prefix is BlobLimitPrefixMebi) or n gibibytes (when prefix is BlobLimitPrefixGibi). n can be zero, in which case all blobs will be omitted.

func FilterBlobNone

func FilterBlobNone() Filter

FilterBlobNone omits all blobs.

func FilterCombine

func FilterCombine(filters ...Filter) Filter

FilterCombine combines multiple Filter values together.

func FilterObjectType

func FilterObjectType(t plumbing.ObjectType) (Filter, error)

FilterObjectType omits all objects which are not of the requested type t. Supported types are TagObject, CommitObject, TreeObject and BlobObject.

func FilterTreeDepth

func FilterTreeDepth(depth uint64) Filter

FilterTreeDepth omits all blobs and trees whose depth from the root tree is larger or equal to depth.

type GitProtoRequest

type GitProtoRequest struct {
	RequestCommand string
	Pathname       string

	// Optional
	Host string

	// Optional
	ExtraParams []string
}

GitProtoRequest is a command request for the git protocol. It is used to send the command, endpoint, and extra parameters to the remote. See https://git-scm.com/docs/pack-protocol#_git_transport

func (*GitProtoRequest) Decode

func (g *GitProtoRequest) Decode(r io.Reader) error

Decode decodes the request from the reader.

func (*GitProtoRequest) Encode

func (g *GitProtoRequest) Encode(w io.Writer) error

Encode encodes the request into the writer.

type InfoRefs

type InfoRefs struct {
	// References are the hash references, including peeled refs (whose
	// names end in ^{}). They are stored in the order received from the
	// server.
	References []*plumbing.Reference
}

InfoRefs represents the information of the references advertised by an HTTP dumb server.

func (*InfoRefs) Decode

func (i *InfoRefs) Decode(r io.Reader) error

Decode decodes an InfoRefs from reader.

func (*InfoRefs) Encode

func (i *InfoRefs) Encode(w io.Writer) error

Encode encodes an InfoRefs to writer.

type LsRefsArgs

type LsRefsArgs struct {
	Peel        bool
	Symrefs     bool
	Unborn      bool
	RefPrefixes []string
}

LsRefsArgs represents the arguments for the v2 ls-refs command. It is encoded as the command-specific arguments and a flush-pkt in a v2 command request.

func (*LsRefsArgs) Decode

func (r *LsRefsArgs) Decode(rd io.Reader) error

Decode reads ls-refs arguments from a reader until a flush-pkt is encountered.

func (*LsRefsArgs) Encode

func (r *LsRefsArgs) Encode(w io.Writer) error

Encode writes the ls-refs arguments to a writer. Each argument is written as a separate pkt-line. The caller is responsible for writing the delim-pkt before and the flush-pkt after these arguments.

type LsRefsOutput

type LsRefsOutput struct {
	References []*plumbing.Reference
}

LsRefsOutput represents the server response to an ls-refs command.

Each ref line has the format:

<oid> SP <refname> [SP symref-target:<target>] [SP peeled:<oid>]

or for unborn refs:

unborn SP <refname> SP symref-target:<target>

The response ends with a flush-pkt. For HTTP, response-end (0002) is consumed by the transport layer and not seen by Decode.

func (*LsRefsOutput) Decode

func (r *LsRefsOutput) Decode(rd io.Reader) error

Decode reads ref lines until a flush-pkt.

func (*LsRefsOutput) Encode

func (r *LsRefsOutput) Encode(w io.Writer) error

Encode writes the ls-refs response lines as pkt-lines following the v2 grammar: "<oid> SP <refname> [SP symref-target:<target>] [SP peeled:<oid>]", or "unborn SP <refname> SP symref-target:<target>" for an unborn HEAD. Peeled "^{}" entries are folded into their base ref's line as a peeled attribute, and a symbolic ref carries the resolved oid of its target when present. The caller is responsible for writing the flush-pkt after these lines.

type MalformedResponseError

type MalformedResponseError struct {
	Reason string
}

MalformedResponseError reports a server response that violates the gitprotocol-v2 grammar: a malformed pkt-line, an unrecognized line within a section, an unexpected/repeated/out-of-order section, or a section terminator that contradicts the response shape. It mirrors the situations where upstream fetch-pack.c calls die() on the response.

func (*MalformedResponseError) Error

func (e *MalformedResponseError) Error() string

type PackfileURIs

type PackfileURIs struct {
	// URIs is the list of alternate URIs the server suggests for fetching the
	// packfile.
	URIs []string
}

PackfileURIs represents the server response to a v2 fetch command's packfile-uris section. It is used by the transport layer to determine which alternate URIs the server suggests for fetching the packfile.

type PushOptions

type PushOptions struct {
	Options []string
}

PushOptions represents a list of update request push-options.

See https://git-scm.com/docs/gitprotocol-pack#_reference_update_request_and_packfile_transfer

func (*PushOptions) Decode

func (opts *PushOptions) Decode(r io.Reader) error

Decode decodes the push options from the given reader.

func (*PushOptions) Encode

func (opts *PushOptions) Encode(w io.Writer) error

Encode encodes the push options into the given writer.

type ReportStatus

type ReportStatus struct {
	UnpackStatus    string
	CommandStatuses []*CommandStatus
}

ReportStatus is a report status message, as used in the git-receive-pack process whenever the 'report-status' capability is negotiated. The zero value is safe to use.

func (*ReportStatus) Decode

func (s *ReportStatus) Decode(r io.Reader) error

Decode reads from the given reader and decodes a report-status message. It does not read more input than what is needed to fill the report status.

func (*ReportStatus) Encode

func (s *ReportStatus) Encode(w io.Writer) error

Encode writes the report status to a writer.

func (*ReportStatus) Error

func (s *ReportStatus) Error() error

Error returns the first error if any.

type ServerResponse

type ServerResponse struct {
	ACKs []ACK
}

ServerResponse object acknowledgement from upload-pack service

func (*ServerResponse) Decode

func (r *ServerResponse) Decode(reader io.Reader) error

Decode decodes the response into the struct.

func (*ServerResponse) Encode

func (r *ServerResponse) Encode(w io.Writer) error

Encode encodes the ServerResponse into a writer.

type ShallowInfo

type ShallowInfo struct {
	// Shallows is the list of shallow object IDs sent by the server.
	Shallows []plumbing.Hash
	// Unshallows is the list of object IDs that are no longer shallow.
	Unshallows []plumbing.Hash
}

ShallowInfo represents the server response to a v2 fetch command's shallow-info section. It is used by the transport layer to update the client's shallow boundary after a fetch.

type ShallowUpdate

type ShallowUpdate struct {
	Shallows   []plumbing.Hash
	Unshallows []plumbing.Hash
}

ShallowUpdate represents shallow/unshallow updates during fetch.

func (*ShallowUpdate) Decode

func (r *ShallowUpdate) Decode(reader io.Reader) error

Decode parses shallow update information from the reader.

func (*ShallowUpdate) Encode

func (r *ShallowUpdate) Encode(w io.Writer) error

Encode writes the shallow update to the writer.

type SmartReply

type SmartReply struct {
	Service string
}

SmartReply represents Git HTTP smart protocol service payload.

When sending a message over (smart) HTTP, you have to add a pktline before the whole thing with the following payload:

'# service=$servicename" LF

Moreover, some if not all, git HTTP smart servers will send a flush-pkt just after the first pkt-line.

func (*SmartReply) Decode

func (s *SmartReply) Decode(r io.Reader) error

Decode decodes a SmartReply from reader.

func (*SmartReply) Encode

func (s *SmartReply) Encode(w io.Writer) error

Encode encodes a SmartReply to writer.

type UnpackStatusErr

type UnpackStatusErr struct {
	Status string
}

UnpackStatusErr is the error returned when the report status is not ok.

func (UnpackStatusErr) Error

func (e UnpackStatusErr) Error() string

Error implements the error interface.

type UpdateRequests

type UpdateRequests struct {
	Capabilities capability.List
	Commands     []*Command
	Shallows     []plumbing.Hash
}

UpdateRequests values represent reference upload requests. The zero value is safe to use; Commands and Shallows can be populated via append.

func (*UpdateRequests) Decode

func (req *UpdateRequests) Decode(r io.Reader) error

Decode reads the next update-request message from the reader.

func (*UpdateRequests) Encode

func (req *UpdateRequests) Encode(w io.Writer) error

Encode writes the ReferenceUpdateRequest encoding to the stream.

type UploadHaves

type UploadHaves struct {
	Haves []plumbing.Hash
	Done  bool
}

UploadHaves is a message to signal the references that a client has in a upload-pack. Done is true when the client has sent a "done" message. Otherwise, it means that the client has more haves to send and this request was completed with a flush.

func (*UploadHaves) Decode

func (u *UploadHaves) Decode(r io.Reader) error

Decode decodes the UploadHaves from the Reader.

func (*UploadHaves) Encode

func (u *UploadHaves) Encode(w io.Writer) error

Encode encodes the UploadHaves into the Writer.

type UploadRequest

type UploadRequest struct {
	Capabilities capability.List
	Wants        []plumbing.Hash
	Shallows     []plumbing.Hash
	Depth        DepthRequest
	Filter       Filter
}

UploadRequest values represent the information transmitted on a upload-request message. The zero value is safe to use; Wants, Shallows and Capabilities can be populated via append.

func (*UploadRequest) Decode

func (req *UploadRequest) Decode(r io.Reader) error

Decode reads the next upload-request from its input and stores it in the UploadRequest.

func (*UploadRequest) Encode

func (req *UploadRequest) Encode(w io.Writer) error

Encode writes the UlReq encoding of u to the stream.

All the payloads will end with a newline character. Wants and shallows are sorted alphabetically. A depth of 0 means no depth request is sent.

type WantedRefs

type WantedRefs struct {
	// Refs is the list of references sent by the server.
	Refs []*plumbing.Reference
}

WantedRefs represents the server response to a v2 fetch command's wanted-refs section. It is used by the transport layer to determine which references the server wants the client to have.

Directories

Path Synopsis
Package sideband implements a sideband multiplex/demultiplexer
Package sideband implements a sideband multiplex/demultiplexer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL