Ejemplo n.º 1
0
func formatCaps(c *capability.List) string {
	if c == nil {
		return ""
	}

	return c.String()
}
Ejemplo n.º 2
0
// NewReferenceUpdateRequestFromCapabilities returns a pointer to a new
// ReferenceUpdateRequest value, the request capabilities are filled with the
// most optimal ones, based on the adv value (advertised capabilities), the
// ReferenceUpdateRequest contains no commands
//
// It does set the following capabilities:
//   - agent
//   - report-status
//   - ofs-delta
//   - ref-delta
// It leaves up to the user to add the following capabilities later:
//   - atomic
//   - ofs-delta
//   - side-band
//   - side-band-64k
//   - quiet
//   - push-cert
func NewReferenceUpdateRequestFromCapabilities(adv *capability.List) *ReferenceUpdateRequest {
	r := NewReferenceUpdateRequest()

	if adv.Supports(capability.Agent) {
		r.Capabilities.Set(capability.Agent, capability.DefaultAgent)
	}

	if adv.Supports(capability.ReportStatus) {
		r.Capabilities.Set(capability.ReportStatus)
	}

	return r
}
Ejemplo n.º 3
0
func (r *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder,
	cmds []*Command, cap *capability.List) error {

	if err := e.Encodef("%s\x00%s",
		formatCommand(cmds[0]), cap.String()); err != nil {
		return err
	}

	for _, cmd := range cmds[1:] {
		if err := e.Encodef(formatCommand(cmd)); err != nil {
			return err
		}
	}

	return e.Flush()
}
Ejemplo n.º 4
0
func buildSidebandIfSupported(l *capability.List, reader io.Reader, p sideband.Progress) io.Reader {
	var t sideband.Type

	switch {
	case l.Supports(capability.Sideband):
		t = sideband.Sideband
	case l.Supports(capability.Sideband64k):
		t = sideband.Sideband64k
	default:
		return reader
	}

	d := sideband.NewDemuxer(t, reader)
	d.Progress = p

	return d
}
Ejemplo n.º 5
0
// NewUploadRequestFromCapabilities returns a pointer to a new UploadRequest
// value, the request capabilities are filled with the most optiomal ones, based
// on the adv value (advertaised capabilities), the UploadRequest generated it
// has no wants or shallows and an infinite depth.
func NewUploadRequestFromCapabilities(adv *capability.List) *UploadRequest {
	r := NewUploadRequest()

	if adv.Supports(capability.MultiACKDetailed) {
		r.Capabilities.Set(capability.MultiACKDetailed)
	} else if adv.Supports(capability.MultiACK) {
		r.Capabilities.Set(capability.MultiACK)
	}

	if adv.Supports(capability.Sideband64k) {
		r.Capabilities.Set(capability.Sideband64k)
	} else if adv.Supports(capability.Sideband) {
		r.Capabilities.Set(capability.Sideband)
	}

	if adv.Supports(capability.ThinPack) {
		r.Capabilities.Set(capability.ThinPack)
	}

	if adv.Supports(capability.OFSDelta) {
		r.Capabilities.Set(capability.OFSDelta)
	}

	if adv.Supports(capability.Agent) {
		r.Capabilities.Set(capability.Agent, capability.DefaultAgent)
	}

	return r
}
Ejemplo n.º 6
0
// FilterUnsupportedCapabilities it filter out all the UnsupportedCapabilities
// from a capability.List, the intended usage is on the client implementation
// to filter the capabilities from an AdvRefs message.
func FilterUnsupportedCapabilities(list *capability.List) {
	for _, c := range UnsupportedCapabilities {
		list.Delete(c)
	}
}