MCPcopy
hub / github.com/go-git/go-git / parentsContainingPath

Function parentsContainingPath

blame.go:548–579  ·  view source on GitHub ↗
(path string, c *object.Commit)

Source from the content-addressed store, hash-verified

546}
547
548func parentsContainingPath(path string, c *object.Commit) ([]parentCommit, error) {
549 // TODO: benchmark this method making git.object.Commit.parent public instead of using
550 // an iterator
551 var result []parentCommit
552 iter := c.Parents()
553 for {
554 parent, err := iter.Next()
555 if err == io.EOF {
556 return result, nil
557 }
558 if err != nil {
559 return nil, err
560 }
561 if _, err := parent.File(path); err == nil {
562 result = append(result, parentCommit{parent, path})
563 } else {
564 // look for renames
565 patch, err := parent.Patch(c)
566 if err != nil {
567 return nil, err
568 } else if patch != nil {
569 for _, fp := range patch.FilePatches() {
570 from, to := fp.Files()
571 if from != nil && to != nil && to.Path() == path {
572 result = append(result, parentCommit{parent, from.Path()})
573 break
574 }
575 }
576 }
577 }
578 }
579}
580
581func blobHash(path string, commit *object.Commit) (plumbing.Hash, error) {
582 file, err := commit.File(path)

Callers 1

addBlamesMethod · 0.85

Calls 7

ParentsMethod · 0.80
NextMethod · 0.65
FilePatchesMethod · 0.65
FilesMethod · 0.65
PathMethod · 0.65
FileMethod · 0.45
PatchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…