(s storer.EncodedObjectStorer, remoteRefs storer.ReferenceStorer, cmd *packp.Command)
| 1095 | } |
| 1096 | |
| 1097 | func 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 | |
| 1123 | func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earliestShallow *plumbing.Hash) (bool, error) { |
| 1124 | c, err := object.GetCommit(s, new) |
no test coverage detected
searching dependent graphs…