mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-15 01:34:26 +02:00
Bump go-git
This commit is contained in:
14
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/advrefs.go
generated
vendored
14
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/advrefs.go
generated
vendored
@ -57,7 +57,7 @@ func (a *AdvRefs) AddReference(r *plumbing.Reference) error {
|
||||
switch r.Type() {
|
||||
case plumbing.SymbolicReference:
|
||||
v := fmt.Sprintf("%s:%s", r.Name().String(), r.Target().String())
|
||||
a.Capabilities.Add(capability.SymRef, v)
|
||||
return a.Capabilities.Add(capability.SymRef, v)
|
||||
case plumbing.HashReference:
|
||||
a.References[r.Name().String()] = r.Hash()
|
||||
default:
|
||||
@ -96,12 +96,12 @@ func (a *AdvRefs) addRefs(s storer.ReferenceStorer) error {
|
||||
//
|
||||
// Git versions prior to 1.8.4.3 has an special procedure to get
|
||||
// the reference where is pointing to HEAD:
|
||||
// - Check if a reference called master exists. If exists and it
|
||||
// has the same hash as HEAD hash, we can say that HEAD is pointing to master
|
||||
// - If master does not exists or does not have the same hash as HEAD,
|
||||
// order references and check in that order if that reference has the same
|
||||
// hash than HEAD. If yes, set HEAD pointing to that branch hash
|
||||
// - If no reference is found, throw an error
|
||||
// - Check if a reference called master exists. If exists and it
|
||||
// has the same hash as HEAD hash, we can say that HEAD is pointing to master
|
||||
// - If master does not exists or does not have the same hash as HEAD,
|
||||
// order references and check in that order if that reference has the same
|
||||
// hash than HEAD. If yes, set HEAD pointing to that branch hash
|
||||
// - If no reference is found, throw an error
|
||||
func (a *AdvRefs) resolveHead(s storer.ReferenceStorer) error {
|
||||
if a.Head == nil {
|
||||
return nil
|
||||
|
1
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/advrefs_decode.go
generated
vendored
1
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/advrefs_decode.go
generated
vendored
@ -133,6 +133,7 @@ func decodeFirstHash(p *advRefsDecoder) decoderStateFn {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: Use object-format (when available) for hash size. Git 2.41+
|
||||
if len(p.line) < hashSize {
|
||||
p.error("cannot read hash, pkt-line too short")
|
||||
return nil
|
||||
|
@ -1,6 +1,11 @@
|
||||
// Package capability defines the server and client capabilities.
|
||||
package capability
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Capability describes a server or client capability.
|
||||
type Capability string
|
||||
|
||||
@ -230,9 +235,23 @@ const (
|
||||
PushCert Capability = "push-cert"
|
||||
// SymRef symbolic reference support for better negotiation.
|
||||
SymRef Capability = "symref"
|
||||
// ObjectFormat takes a hash algorithm as an argument, indicates that the
|
||||
// server supports the given hash algorithms.
|
||||
ObjectFormat Capability = "object-format"
|
||||
// Filter if present, fetch-pack may send "filter" commands to request a
|
||||
// partial clone or partial fetch and request that the server omit various objects from the packfile
|
||||
Filter Capability = "filter"
|
||||
)
|
||||
|
||||
const DefaultAgent = "go-git/4.x"
|
||||
const userAgent = "go-git/5.x"
|
||||
|
||||
// DefaultAgent provides the user agent string.
|
||||
func DefaultAgent() string {
|
||||
if envUserAgent, ok := os.LookupEnv("GO_GIT_USER_AGENT_EXTRA"); ok {
|
||||
return fmt.Sprintf("%s %s", userAgent, envUserAgent)
|
||||
}
|
||||
return userAgent
|
||||
}
|
||||
|
||||
var known = map[Capability]bool{
|
||||
MultiACK: true, MultiACKDetailed: true, NoDone: true, ThinPack: true,
|
||||
@ -241,10 +260,11 @@ var known = map[Capability]bool{
|
||||
NoProgress: true, IncludeTag: true, ReportStatus: true, DeleteRefs: true,
|
||||
Quiet: true, Atomic: true, PushOptions: true, AllowTipSHA1InWant: true,
|
||||
AllowReachableSHA1InWant: true, PushCert: true, SymRef: true,
|
||||
ObjectFormat: true, Filter: true,
|
||||
}
|
||||
|
||||
var requiresArgument = map[Capability]bool{
|
||||
Agent: true, PushCert: true, SymRef: true,
|
||||
Agent: true, PushCert: true, SymRef: true, ObjectFormat: true,
|
||||
}
|
||||
|
||||
var multipleArgument = map[Capability]bool{
|
||||
|
4
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/capability/list.go
generated
vendored
4
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/capability/list.go
generated
vendored
@ -86,7 +86,9 @@ func (l *List) Get(capability Capability) []string {
|
||||
|
||||
// Set sets a capability removing the previous values
|
||||
func (l *List) Set(capability Capability, values ...string) error {
|
||||
delete(l.m, capability)
|
||||
if _, ok := l.m[capability]; ok {
|
||||
l.m[capability].Values = l.m[capability].Values[:0]
|
||||
}
|
||||
return l.Add(capability, values...)
|
||||
}
|
||||
|
||||
|
6
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/common.go
generated
vendored
6
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/common.go
generated
vendored
@ -19,7 +19,6 @@ var (
|
||||
// common
|
||||
sp = []byte(" ")
|
||||
eol = []byte("\n")
|
||||
eq = []byte{'='}
|
||||
|
||||
// advertised-refs
|
||||
null = []byte("\x00")
|
||||
@ -49,6 +48,11 @@ func isFlush(payload []byte) bool {
|
||||
return len(payload) == 0
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrNilWriter is returned when a nil writer is passed to the encoder.
|
||||
ErrNilWriter = fmt.Errorf("nil writer")
|
||||
)
|
||||
|
||||
// ErrUnexpectedData represents an unexpected data decoding a message
|
||||
type ErrUnexpectedData struct {
|
||||
Msg string
|
||||
|
76
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/filter.go
generated
vendored
Normal file
76
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/filter.go
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
package packp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/jesseduffield/go-git/v5/plumbing"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ErrUnsupportedObjectFilterType = errors.New("unsupported object filter type")
|
||||
|
||||
// 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.
|
||||
//
|
||||
// [Git's documentation]: https://github.com/git/git/blob/e02ecfcc534e2021aae29077a958dd11c3897e4c/Documentation/rev-list-options.txt#L948
|
||||
type Filter string
|
||||
|
||||
type BlobLimitPrefix string
|
||||
|
||||
const (
|
||||
BlobLimitPrefixNone BlobLimitPrefix = ""
|
||||
BlobLimitPrefixKibi BlobLimitPrefix = "k"
|
||||
BlobLimitPrefixMebi BlobLimitPrefix = "m"
|
||||
BlobLimitPrefixGibi BlobLimitPrefix = "g"
|
||||
)
|
||||
|
||||
// FilterBlobNone omits all blobs.
|
||||
func FilterBlobNone() Filter {
|
||||
return "blob:none"
|
||||
}
|
||||
|
||||
// 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 FilterBlobLimit(n uint64, prefix BlobLimitPrefix) Filter {
|
||||
return Filter(fmt.Sprintf("blob:limit=%d%s", n, prefix))
|
||||
}
|
||||
|
||||
// FilterTreeDepth omits all blobs and trees whose depth from the root tree
|
||||
// is larger or equal to depth.
|
||||
func FilterTreeDepth(depth uint64) Filter {
|
||||
return Filter(fmt.Sprintf("tree:%d", depth))
|
||||
}
|
||||
|
||||
// FilterObjectType omits all objects which are not of the requested type t.
|
||||
// Supported types are TagObject, CommitObject, TreeObject and BlobObject.
|
||||
func FilterObjectType(t plumbing.ObjectType) (Filter, error) {
|
||||
switch t {
|
||||
case plumbing.TagObject:
|
||||
fallthrough
|
||||
case plumbing.CommitObject:
|
||||
fallthrough
|
||||
case plumbing.TreeObject:
|
||||
fallthrough
|
||||
case plumbing.BlobObject:
|
||||
return Filter(fmt.Sprintf("object:type=%s", t.String())), nil
|
||||
default:
|
||||
return "", fmt.Errorf("%w: %s", ErrUnsupportedObjectFilterType, t.String())
|
||||
}
|
||||
}
|
||||
|
||||
// FilterCombine combines multiple Filter values together.
|
||||
func FilterCombine(filters ...Filter) Filter {
|
||||
var escapedFilters []string
|
||||
|
||||
for _, filter := range filters {
|
||||
escapedFilters = append(escapedFilters, url.QueryEscape(string(filter)))
|
||||
}
|
||||
|
||||
return Filter(fmt.Sprintf("combine:%s", strings.Join(escapedFilters, "+")))
|
||||
}
|
120
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/gitproto.go
generated
vendored
Normal file
120
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/gitproto.go
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
package packp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/go-git/v5/plumbing/format/pktline"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidGitProtoRequest is returned by Decode if the input is not a
|
||||
// valid git protocol request.
|
||||
ErrInvalidGitProtoRequest = fmt.Errorf("invalid git protocol request")
|
||||
)
|
||||
|
||||
// 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
|
||||
type GitProtoRequest struct {
|
||||
RequestCommand string
|
||||
Pathname string
|
||||
|
||||
// Optional
|
||||
Host string
|
||||
|
||||
// Optional
|
||||
ExtraParams []string
|
||||
}
|
||||
|
||||
// validate validates the request.
|
||||
func (g *GitProtoRequest) validate() error {
|
||||
if g.RequestCommand == "" {
|
||||
return fmt.Errorf("%w: empty request command", ErrInvalidGitProtoRequest)
|
||||
}
|
||||
|
||||
if g.Pathname == "" {
|
||||
return fmt.Errorf("%w: empty pathname", ErrInvalidGitProtoRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode encodes the request into the writer.
|
||||
func (g *GitProtoRequest) Encode(w io.Writer) error {
|
||||
if w == nil {
|
||||
return ErrNilWriter
|
||||
}
|
||||
|
||||
if err := g.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
p := pktline.NewEncoder(w)
|
||||
req := fmt.Sprintf("%s %s\x00", g.RequestCommand, g.Pathname)
|
||||
if host := g.Host; host != "" {
|
||||
req += fmt.Sprintf("host=%s\x00", host)
|
||||
}
|
||||
|
||||
if len(g.ExtraParams) > 0 {
|
||||
req += "\x00"
|
||||
for _, param := range g.ExtraParams {
|
||||
req += param + "\x00"
|
||||
}
|
||||
}
|
||||
|
||||
if err := p.Encode([]byte(req)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode decodes the request from the reader.
|
||||
func (g *GitProtoRequest) Decode(r io.Reader) error {
|
||||
s := pktline.NewScanner(r)
|
||||
if !s.Scan() {
|
||||
err := s.Err()
|
||||
if err == nil {
|
||||
return ErrInvalidGitProtoRequest
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
line := string(s.Bytes())
|
||||
if len(line) == 0 {
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
if line[len(line)-1] != 0 {
|
||||
return fmt.Errorf("%w: missing null terminator", ErrInvalidGitProtoRequest)
|
||||
}
|
||||
|
||||
parts := strings.SplitN(line, " ", 2)
|
||||
if len(parts) != 2 {
|
||||
return fmt.Errorf("%w: short request", ErrInvalidGitProtoRequest)
|
||||
}
|
||||
|
||||
g.RequestCommand = parts[0]
|
||||
params := strings.Split(parts[1], string(null))
|
||||
if len(params) < 1 {
|
||||
return fmt.Errorf("%w: missing pathname", ErrInvalidGitProtoRequest)
|
||||
}
|
||||
|
||||
g.Pathname = params[0]
|
||||
if len(params) > 1 {
|
||||
g.Host = strings.TrimPrefix(params[1], "host=")
|
||||
}
|
||||
|
||||
if len(params) > 2 {
|
||||
for _, param := range params[2:] {
|
||||
if param != "" {
|
||||
g.ExtraParams = append(g.ExtraParams, param)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
2
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/sideband/demux.go
generated
vendored
2
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/sideband/demux.go
generated
vendored
@ -114,7 +114,7 @@ func (d *Demuxer) nextPackData() ([]byte, error) {
|
||||
|
||||
size := len(content)
|
||||
if size == 0 {
|
||||
return nil, nil
|
||||
return nil, io.EOF
|
||||
} else if size > d.max {
|
||||
return nil, ErrMaxPackedExceeded
|
||||
}
|
||||
|
43
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/srvresp.go
generated
vendored
43
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/srvresp.go
generated
vendored
@ -21,11 +21,6 @@ type ServerResponse struct {
|
||||
// Decode decodes the response into the struct, isMultiACK should be true, if
|
||||
// the request was done with multi_ack or multi_ack_detailed capabilities.
|
||||
func (r *ServerResponse) Decode(reader *bufio.Reader, isMultiACK bool) error {
|
||||
// TODO: implement support for multi_ack or multi_ack_detailed responses
|
||||
if isMultiACK {
|
||||
return errors.New("multi_ack and multi_ack_detailed are not supported")
|
||||
}
|
||||
|
||||
s := pktline.NewScanner(reader)
|
||||
|
||||
for s.Scan() {
|
||||
@ -48,7 +43,23 @@ func (r *ServerResponse) Decode(reader *bufio.Reader, isMultiACK bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
return s.Err()
|
||||
// isMultiACK is true when the remote server advertises the related
|
||||
// capabilities when they are not in transport.UnsupportedCapabilities.
|
||||
//
|
||||
// Users may decide to remove multi_ack and multi_ack_detailed from the
|
||||
// unsupported capabilities list, which allows them to do initial clones
|
||||
// from Azure DevOps.
|
||||
//
|
||||
// Follow-up fetches may error, therefore errors are wrapped with additional
|
||||
// information highlighting that this capabilities are not supported by go-git.
|
||||
//
|
||||
// TODO: Implement support for multi_ack or multi_ack_detailed responses.
|
||||
err := s.Err()
|
||||
if err != nil && isMultiACK {
|
||||
return fmt.Errorf("multi_ack and multi_ack_detailed are not supported: %w", err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// stopReading detects when a valid command such as ACK or NAK is found to be
|
||||
@ -90,12 +101,14 @@ func (r *ServerResponse) decodeLine(line []byte) error {
|
||||
return fmt.Errorf("unexpected flush")
|
||||
}
|
||||
|
||||
if bytes.Equal(line[0:3], ack) {
|
||||
return r.decodeACKLine(line)
|
||||
}
|
||||
if len(line) >= 3 {
|
||||
if bytes.Equal(line[0:3], ack) {
|
||||
return r.decodeACKLine(line)
|
||||
}
|
||||
|
||||
if bytes.Equal(line[0:3], nak) {
|
||||
return nil
|
||||
if bytes.Equal(line[0:3], nak) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("unexpected content %q", string(line))
|
||||
@ -107,14 +120,18 @@ func (r *ServerResponse) decodeACKLine(line []byte) error {
|
||||
}
|
||||
|
||||
sp := bytes.Index(line, []byte(" "))
|
||||
if sp+41 > len(line) {
|
||||
return fmt.Errorf("malformed ACK %q", line)
|
||||
}
|
||||
h := plumbing.NewHash(string(line[sp+1 : sp+41]))
|
||||
r.ACKs = append(r.ACKs, h)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode encodes the ServerResponse into a writer.
|
||||
func (r *ServerResponse) Encode(w io.Writer) error {
|
||||
if len(r.ACKs) > 1 {
|
||||
func (r *ServerResponse) Encode(w io.Writer, isMultiACK bool) error {
|
||||
if len(r.ACKs) > 1 && !isMultiACK {
|
||||
// For further information, refer to comments in the Decode func above.
|
||||
return errors.New("multi_ack and multi_ack_detailed are not supported")
|
||||
}
|
||||
|
||||
|
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq.go
generated
vendored
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq.go
generated
vendored
@ -17,6 +17,7 @@ type UploadRequest struct {
|
||||
Wants []plumbing.Hash
|
||||
Shallows []plumbing.Hash
|
||||
Depth Depth
|
||||
Filter Filter
|
||||
}
|
||||
|
||||
// Depth values stores the desired depth of the requested packfile: see
|
||||
@ -95,7 +96,7 @@ func NewUploadRequestFromCapabilities(adv *capability.List) *UploadRequest {
|
||||
}
|
||||
|
||||
if adv.Supports(capability.Agent) {
|
||||
r.Capabilities.Set(capability.Agent, capability.DefaultAgent)
|
||||
r.Capabilities.Set(capability.Agent, capability.DefaultAgent())
|
||||
}
|
||||
|
||||
return r
|
||||
|
2
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq_decode.go
generated
vendored
2
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq_decode.go
generated
vendored
@ -43,7 +43,7 @@ func (d *ulReqDecoder) Decode(v *UploadRequest) error {
|
||||
return d.err
|
||||
}
|
||||
|
||||
// fills out the parser stiky error
|
||||
// fills out the parser sticky error
|
||||
func (d *ulReqDecoder) error(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(
|
||||
"pkt-line %d: %s", d.nLine,
|
||||
|
11
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq_encode.go
generated
vendored
11
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/ulreq_encode.go
generated
vendored
@ -132,6 +132,17 @@ func (e *ulReqEncoder) encodeDepth() stateFn {
|
||||
return nil
|
||||
}
|
||||
|
||||
return e.encodeFilter
|
||||
}
|
||||
|
||||
func (e *ulReqEncoder) encodeFilter() stateFn {
|
||||
if filter := e.data.Filter; filter != "" {
|
||||
if err := e.pe.Encodef("filter %s\n", filter); err != nil {
|
||||
e.err = fmt.Errorf("encoding filter %s: %s", filter, err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return e.encodeFlush
|
||||
}
|
||||
|
||||
|
14
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq.go
generated
vendored
14
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq.go
generated
vendored
@ -19,6 +19,7 @@ var (
|
||||
type ReferenceUpdateRequest struct {
|
||||
Capabilities *capability.List
|
||||
Commands []*Command
|
||||
Options []*Option
|
||||
Shallow *plumbing.Hash
|
||||
// Packfile contains an optional packfile reader.
|
||||
Packfile io.ReadCloser
|
||||
@ -58,7 +59,7 @@ func NewReferenceUpdateRequestFromCapabilities(adv *capability.List) *ReferenceU
|
||||
r := NewReferenceUpdateRequest()
|
||||
|
||||
if adv.Supports(capability.Agent) {
|
||||
r.Capabilities.Set(capability.Agent, capability.DefaultAgent)
|
||||
r.Capabilities.Set(capability.Agent, capability.DefaultAgent())
|
||||
}
|
||||
|
||||
if adv.Supports(capability.ReportStatus) {
|
||||
@ -86,9 +87,9 @@ type Action string
|
||||
|
||||
const (
|
||||
Create Action = "create"
|
||||
Update = "update"
|
||||
Delete = "delete"
|
||||
Invalid = "invalid"
|
||||
Update Action = "update"
|
||||
Delete Action = "delete"
|
||||
Invalid Action = "invalid"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
@ -120,3 +121,8 @@ func (c *Command) validate() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Option struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq_decode.go
generated
vendored
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq_decode.go
generated
vendored
@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/jesseduffield/go-git/v5/plumbing"
|
||||
"github.com/jesseduffield/go-git/v5/plumbing/format/pktline"
|
||||
@ -81,7 +80,7 @@ func (req *ReferenceUpdateRequest) Decode(r io.Reader) error {
|
||||
var ok bool
|
||||
rc, ok = r.(io.ReadCloser)
|
||||
if !ok {
|
||||
rc = ioutil.NopCloser(r)
|
||||
rc = io.NopCloser(r)
|
||||
}
|
||||
|
||||
d := &updReqDecoder{r: rc, s: pktline.NewScanner(r)}
|
||||
|
22
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq_encode.go
generated
vendored
22
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/updreq_encode.go
generated
vendored
@ -9,10 +9,6 @@ import (
|
||||
"github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/capability"
|
||||
)
|
||||
|
||||
var (
|
||||
zeroHashString = plumbing.ZeroHash.String()
|
||||
)
|
||||
|
||||
// Encode writes the ReferenceUpdateRequest encoding to the stream.
|
||||
func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
|
||||
if err := req.validate(); err != nil {
|
||||
@ -29,6 +25,12 @@ func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if req.Capabilities.Supports(capability.PushOptions) {
|
||||
if err := req.encodeOptions(e, req.Options); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if req.Packfile != nil {
|
||||
if _, err := io.Copy(w, req.Packfile); err != nil {
|
||||
return err
|
||||
@ -73,3 +75,15 @@ func formatCommand(cmd *Command) string {
|
||||
n := cmd.New.String()
|
||||
return fmt.Sprintf("%s %s %s", o, n, cmd.Name)
|
||||
}
|
||||
|
||||
func (req *ReferenceUpdateRequest) encodeOptions(e *pktline.Encoder,
|
||||
opts []*Option) error {
|
||||
|
||||
for _, opt := range opts {
|
||||
if err := e.Encodef("%s=%s", opt.Key, opt.Value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return e.Flush()
|
||||
}
|
||||
|
6
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/uppackreq.go
generated
vendored
6
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/uppackreq.go
generated
vendored
@ -38,10 +38,10 @@ func NewUploadPackRequestFromCapabilities(adv *capability.List) *UploadPackReque
|
||||
}
|
||||
}
|
||||
|
||||
// IsEmpty a request if empty if Haves are contained in the Wants, or if Wants
|
||||
// length is zero
|
||||
// IsEmpty returns whether a request is empty - it is empty if Haves are contained
|
||||
// in the Wants, or if Wants length is zero, and we don't have any shallows
|
||||
func (r *UploadPackRequest) IsEmpty() bool {
|
||||
return isSubset(r.Wants, r.Haves)
|
||||
return isSubset(r.Wants, r.Haves) && len(r.Shallows) == 0
|
||||
}
|
||||
|
||||
func isSubset(needle []plumbing.Hash, haystack []plumbing.Hash) bool {
|
||||
|
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/uppackresp.go
generated
vendored
3
vendor/github.com/jesseduffield/go-git/v5/plumbing/protocol/packp/uppackresp.go
generated
vendored
@ -24,7 +24,6 @@ type UploadPackResponse struct {
|
||||
r io.ReadCloser
|
||||
isShallow bool
|
||||
isMultiACK bool
|
||||
isOk bool
|
||||
}
|
||||
|
||||
// NewUploadPackResponse create a new UploadPackResponse instance, the request
|
||||
@ -79,7 +78,7 @@ func (r *UploadPackResponse) Encode(w io.Writer) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.ServerResponse.Encode(w); err != nil {
|
||||
if err := r.ServerResponse.Encode(w, r.isMultiACK); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user