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)
| 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 |
| 101 | func 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 | |
| 120 | func formatCaps(c *capability.List) string { |
| 121 | if c == nil { |
nothing calls this directly
no test coverage detected