MCPcopy Index your code
hub / github.com/google/git-appraise / splitBatchCheckOutput

Function splitBatchCheckOutput

repository/git.go:712–733  ·  view source on GitHub ↗

splitBatchCheckOutput parses the output of a 'git cat-file --batch-check=...' command. The output is expected to be formatted as a series of entries, with each entry consisting of: 1. The SHA1 hash of the git object being output, followed by a space. 2. The git "type" of the object (commit, blob, t

(out *bytes.Buffer)

Source from the content-addressed store, hash-verified

710//
711// The return value is a map from object hash to a boolean indicating if that object is a commit.
712func splitBatchCheckOutput(out *bytes.Buffer) (map[string]bool, error) {
713 isCommit := make(map[string]bool)
714 reader := bufio.NewReader(out)
715 for {
716 nameLine, err := reader.ReadString(byte(' '))
717 if err == io.EOF {
718 return isCommit, nil
719 }
720 if err != nil {
721 return nil, fmt.Errorf("Failure while reading the next object name: %v", err)
722 }
723 nameLine = strings.TrimSuffix(nameLine, " ")
724 typeLine, err := reader.ReadString(byte('\n'))
725 if err != nil && err != io.EOF {
726 return nil, fmt.Errorf("Failure while reading the next object type: %q - %v", nameLine, err)
727 }
728 typeLine = strings.TrimSuffix(typeLine, "\n")
729 if typeLine == "commit" {
730 isCommit[nameLine] = true
731 }
732 }
733}
734
735// splitBatchCatFileOutput parses the output of a 'git cat-file --batch=...' command.
736//

Callers 2

getIsCommitMapMethod · 0.85

Calls

no outgoing calls

Tested by 1