MCPcopy Create free account
hub / github.com/go-git/go-git / encodeFirstLine

Function encodeFirstLine

plumbing/protocol/packp/advrefs_encode.go:101–118  ·  view source on GitHub ↗

Adds the first pkt-line payload: head hash, head ref and capabilities. If HEAD ref is not found, the first reference ordered in increasing order will be used. If there aren't HEAD neither refs, the first line will be "PKT-LINE(zero-id SP "capabilities^{}" NUL capability-list)". See: https://github.c

(e *advRefsEncoder)

Source from the content-addressed store, hash-verified

99// See: https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt
100// See: https://github.com/git/git/blob/master/Documentation/technical/protocol-common.txt
101func encodeFirstLine(e *advRefsEncoder) encoderStateFn {
102 const formatFirstLine = "%s %s\x00%s\n"
103 var firstLine string
104 capabilities := formatCaps(e.data.Capabilities)
105
106 if e.firstRefName == "" {
107 firstLine = fmt.Sprintf(formatFirstLine, plumbing.ZeroHash.String(), "capabilities^{}", capabilities)
108 } else {
109 firstLine = fmt.Sprintf(formatFirstLine, e.firstRefHash.String(), e.firstRefName, capabilities)
110
111 }
112
113 if e.err = e.pe.EncodeString(firstLine); e.err != nil {
114 return nil
115 }
116
117 return encodeRefs
118}
119
120func formatCaps(c *capability.List) string {
121 if c == nil {

Callers

nothing calls this directly

Calls 3

formatCapsFunction · 0.85
EncodeStringMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected