MCPcopy Index your code
hub / github.com/go-git/go-git / isFastForward

Function isFastForward

remote.go:1123–1154  ·  view source on GitHub ↗
(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash)

Source from the content-addressed store, hash-verified

1121}
1122
1123func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash) (bool, error) {
1124 c, err := object.GetCommit(s, new)
1125 if err != nil {
1126 return false, err
1127 }
1128
1129 parentsToIgnore := []plumbing.Hash{}
1130 if earliestShallow != nil {
1131 earliestCommit, err := object.GetCommit(s, *earliestShallow)
1132 if err != nil {
1133 return false, err
1134 }
1135
1136 parentsToIgnore = earliestCommit.ParentHashes
1137 }
1138
1139 found := false
1140 // stop iterating at the earliest shallow commit, ignoring its parents
1141 // note: when pull depth is smaller than the number of new changes on the remote, this fails due to missing parents.
1142 // as far as i can tell, without the commits in-between the shallow pull and the earliest shallow, there's no
1143 // real way of telling whether it will be a fast-forward merge.
1144 iter := object.NewCommitPreorderIter(c, nil, parentsToIgnore)
1145 err = iter.ForEach(func(c *object.Commit) error {
1146 if c.Hash != old {
1147 return nil
1148 }
1149
1150 found = true
1151 return storer.ErrStop
1152 })
1153 return found, err
1154}
1155
1156func (r *Remote) newUploadPackRequest(o *FetchOptions,
1157 ar *packp.AdvRefs) (*packp.UploadPackRequest, error) {

Callers 4

MergeMethod · 0.85
PullContextMethod · 0.85
checkFastForwardUpdateFunction · 0.85

Calls 3

GetCommitFunction · 0.92
NewCommitPreorderIterFunction · 0.92
ForEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…