(s storer.EncodedObjectStorer, remoteRefs storer.ReferenceStorer, cmd *packp.Command)
| 1086 | } |
| 1087 | |
| 1088 | func 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 | |
| 1114 | func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash) (bool, error) { |
| 1115 | c, err := object.GetCommit(s, new) |
no test coverage detected