public void execute(ReceivePack rp) {try {String expTarget = getOldSymref();boolean detach = getNewSymref() != null|| (type == Type.DELETE && expTarget != null);RefUpdate ru = rp.getRepository().updateRef(getRefName(), detach);if (expTarget != null) {if (!ru.getRef().isSymbolic() || !ru.getRef().getTarget().getName().equals(expTarget)) {setResult(Result.LOCK_FAILURE);return;}}ru.setRefLogIdent(rp.getRefLogIdent());ru.setRefLogMessage(refLogMessage, refLogIncludeResult);switch (getType()) {case DELETE:if (!ObjectId.zeroId().equals(getOldId())) {ru.setExpectedOldObjectId(getOldId());}ru.setForceUpdate(true);setResult(ru.delete(rp.getRevWalk()));break;case CREATE:case UPDATE:case UPDATE_NONFASTFORWARD:ru.setForceUpdate(rp.isAllowNonFastForwards());ru.setExpectedOldObjectId(getOldId());ru.setRefLogMessage("push", true); if (getNewSymref() != null) {setResult(ru.link(getNewSymref()));} else {ru.setNewObjectId(getNewId());setResult(ru.update(rp.getRevWalk()));}break;}} catch (IOException err) {reject(err);}}

public virtual void Execute(BaseReceivePack rp){try{RefUpdate ru = rp.GetRepository().UpdateRef(GetRefName());ru.SetRefLogIdent(rp.GetRefLogIdent());switch (GetType()){case ReceiveCommand.Type.DELETE:{if (!ObjectId.ZeroId.Equals(GetOldId())){ru.SetExpectedOldObjectId(GetOldId());}ru.SetForceUpdate(true);SetResult(ru.Delete(rp.GetRevWalk()));break;}case ReceiveCommand.Type.CREATE:case ReceiveCommand.Type.UPDATE:case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:{ru.SetForceUpdate(rp.IsAllowNonFastForwards());ru.SetExpectedOldObjectId(GetOldId());ru.SetNewObjectId(GetNewId());ru.SetRefLogMessage("push", true);SetResult(ru.Update(rp.GetRevWalk()));break;}}}catch (IOException err){Reject(err);}}
