| 1662 | } |
| 1663 | |
| 1664 | void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, |
| 1665 | int force_update) |
| 1666 | { |
| 1667 | struct ref *ref; |
| 1668 | |
| 1669 | for (ref = remote_refs; ref; ref = ref->next) { |
| 1670 | int force_ref_update = ref->force || force_update; |
| 1671 | int reject_reason = 0; |
| 1672 | |
| 1673 | if (ref->peer_ref) |
| 1674 | oidcpy(&ref->new_oid, &ref->peer_ref->new_oid); |
| 1675 | else if (!send_mirror) |
| 1676 | continue; |
| 1677 | |
| 1678 | ref->deletion = is_null_oid(&ref->new_oid); |
| 1679 | if (!ref->deletion && |
| 1680 | oideq(&ref->old_oid, &ref->new_oid)) { |
| 1681 | ref->status = REF_STATUS_UPTODATE; |
| 1682 | continue; |
| 1683 | } |
| 1684 | |
| 1685 | /* |
| 1686 | * If the remote ref has moved and is now different |
| 1687 | * from what we expect, reject any push. |
| 1688 | * |
| 1689 | * It also is an error if the user told us to check |
| 1690 | * with the remote-tracking branch to find the value |
| 1691 | * to expect, but we did not have such a tracking |
| 1692 | * branch. |
| 1693 | * |
| 1694 | * If the tip of the remote-tracking ref is unreachable |
| 1695 | * from any reflog entry of its local ref indicating a |
| 1696 | * possible update since checkout; reject the push. |
| 1697 | */ |
| 1698 | if (ref->expect_old_sha1) { |
| 1699 | if (!oideq(&ref->old_oid, &ref->old_oid_expect)) |
| 1700 | reject_reason = REF_STATUS_REJECT_STALE; |
| 1701 | else if (ref->check_reachable && ref->unreachable) |
| 1702 | reject_reason = |
| 1703 | REF_STATUS_REJECT_REMOTE_UPDATED; |
| 1704 | else |
| 1705 | /* |
| 1706 | * If the ref isn't stale, and is reachable |
| 1707 | * from one of the reflog entries of |
| 1708 | * the local branch, force the update. |
| 1709 | */ |
| 1710 | force_ref_update = 1; |
| 1711 | } |
| 1712 | |
| 1713 | /* |
| 1714 | * If the update isn't already rejected then check |
| 1715 | * the usual "must fast-forward" rules. |
| 1716 | * |
| 1717 | * Decide whether an individual refspec A:B can be |
| 1718 | * pushed. The push will succeed if any of the |
| 1719 | * following are true: |
| 1720 | * |
| 1721 | * (1) the remote reference B does not exist |
no test coverage detected