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

Method processLine

storage/filesystem/dotgit/dotgit.go:948–966  ·  view source on GitHub ↗

process lines from a packed-refs file

(line string)

Source from the content-addressed store, hash-verified

946
947// process lines from a packed-refs file
948func (d *DotGit) processLine(line string) (*plumbing.Reference, error) {
949 if len(line) == 0 {
950 return nil, nil
951 }
952
953 switch line[0] {
954 case '#': // comment - ignore
955 return nil, nil
956 case '^': // annotated tag commit of the previous line - ignore
957 return nil, nil
958 default:
959 ws := strings.Split(line, " ") // hash then ref
960 if len(ws) != 2 {
961 return nil, ErrPackedRefsBadFormat
962 }
963
964 return plumbing.NewReferenceFromStrings(ws[1], ws[0]), nil
965 }
966}
967
968func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference, seen map[plumbing.ReferenceName]bool) error {
969 return d.walkReferencesTree(refs, []string{refsPath}, seen)

Callers 2

findPackedRefsInFileMethod · 0.95

Calls 1

NewReferenceFromStringsFunction · 0.92

Tested by

no test coverage detected