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

Function checkFastForwardUpdate

remote.go:1097–1121  ·  view source on GitHub ↗
(s storer.EncodedObjectStorer, remoteRefs storer.ReferenceStorer, cmd *packp.Command)

Source from the content-addressed store, hash-verified

1095}
1096
1097func checkFastForwardUpdate(s storer.EncodedObjectStorer, remoteRefs storer.ReferenceStorer, cmd *packp.Command) error {
1098 if cmd.Old == plumbing.ZeroHash {
1099 _, err := remoteRefs.Reference(cmd.Name)
1100 if err == plumbing.ErrReferenceNotFound {
1101 return nil
1102 }
1103
1104 if err != nil {
1105 return err
1106 }
1107
1108 return fmt.Errorf("non-fast-forward update: %s", cmd.Name.String())
1109 }
1110
1111 ff, err := isFastForward(s, cmd.Old, cmd.New, nil)
1112 if err != nil {
1113 return err
1114 }
1115
1116 if !ff {
1117 return fmt.Errorf("non-fast-forward update: %s", cmd.Name.String())
1118 }
1119
1120 return nil
1121}
1122
1123func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash) (bool, error) {
1124 c, err := object.GetCommit(s, new)

Callers 2

addCommitMethod · 0.85

Calls 3

isFastForwardFunction · 0.85
ReferenceMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…