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

Function parentsContainingPath

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

Source from the content-addressed store, hash-verified

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