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

Function checkFastForwardUpdate

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

Source from the content-addressed store, hash-verified

1086}
1087
1088func checkFastForwardUpdate(s storer.EncodedObjectStorer, remoteRefs storer.ReferenceStorer, cmd *packp.Command) error {
1089 if cmd.Old == plumbing.ZeroHash {
1090 _, err := remoteRefs.Reference(cmd.Name)
1091 if err == plumbing.ErrReferenceNotFound {
1092 return nil
1093 }
1094
1095 if err != nil {
1096 return err
1097 }
1098
1099 return fmt.Errorf("non-fast-forward update: %s", cmd.Name.String())
1100 }
1101
1102 ff, err := isFastForward(s, cmd.Old, cmd.New, nil)
1103 if err != nil {
1104 return err
1105 }
1106
1107 if !ff {
1108 return fmt.Errorf("non-fast-forward update: %s", cmd.Name.String())
1109 }
1110
1111 return nil
1112}
1113
1114func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash) (bool, error) {
1115 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