MCPcopy Index your code
hub / github.com/github/git-sizer / ParseBatchHeader

Function ParseBatchHeader

git/batch_header.go:23–47  ·  view source on GitHub ↗

Parse a `cat-file --batch[-check]` output header line (including the trailing LF). `spec`, if not "", is used in error messages.

(spec string, header string)

Source from the content-addressed store, hash-verified

21// Parse a `cat-file --batch[-check]` output header line (including
22// the trailing LF). `spec`, if not "", is used in error messages.
23func ParseBatchHeader(spec string, header string) (BatchHeader, error) {
24 header = header[:len(header)-1]
25 words := strings.Split(header, " ")
26 if words[len(words)-1] == "missing" {
27 if spec == "" {
28 spec = words[0]
29 }
30 return missingHeader, fmt.Errorf("missing object %s", spec)
31 }
32
33 oid, err := NewOID(words[0])
34 if err != nil {
35 return missingHeader, err
36 }
37
38 size, err := strconv.ParseUint(words[2], 10, 0)
39 if err != nil {
40 return missingHeader, err
41 }
42 return BatchHeader{
43 OID: oid,
44 ObjectType: ObjectType(words[1]),
45 ObjectSize: counts.NewCount32(size),
46 }, nil
47}

Callers 2

NewObjectIterMethod · 0.85
NewBatchObjectIterMethod · 0.85

Calls 3

NewCount32Function · 0.92
NewOIDFunction · 0.85
ObjectTypeTypeAlias · 0.85

Tested by

no test coverage detected