// 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 }
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 }
// 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 }