/// <exception cref="NGit.Transport.ServiceMayNotContinueException"></exception>
		public override void AdvertiseRefs(BaseReceivePack receivePack)
		{
			IDictionary<string, Ref> refs = GetAdvertisedRefs(receivePack.GetRepository(), receivePack
				.GetRevWalk());
			ICollection<ObjectId> haves = GetAdvertisedHaves(receivePack.GetRepository(), receivePack
				.GetRevWalk());
			receivePack.SetAdvertisedRefs(refs, haves);
		}
        /// <exception cref="NGit.Transport.ServiceMayNotContinueException"></exception>
        public override void AdvertiseRefs(BaseReceivePack receivePack)
        {
            IDictionary <string, Ref> refs = GetAdvertisedRefs(receivePack.GetRepository(), receivePack
                                                               .GetRevWalk());
            ICollection <ObjectId> haves = GetAdvertisedHaves(receivePack.GetRepository(), receivePack
                                                              .GetRevWalk());

            receivePack.SetAdvertisedRefs(refs, haves);
        }
        /// <summary>Execute this command during a receive-pack session.</summary>
        /// <remarks>
        /// Execute this command during a receive-pack session.
        /// <p>
        /// Sets the status of the command as a side effect.
        /// </remarks>
        /// <param name="rp">receive-pack session.</param>
        /// <since>2.0</since>
        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()))
                    {
                        // We can only do a CAS style delete if the client
                        // didn't bork its delete request by sending the
                        // wrong zero id rather than the advertised one.
                        //
                        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);
            }
        }
예제 #4
0
		/// <summary>Execute this command during a receive-pack session.</summary>
		/// <remarks>
		/// Execute this command during a receive-pack session.
		/// <p>
		/// Sets the status of the command as a side effect.
		/// </remarks>
		/// <param name="rp">receive-pack session.</param>
		/// <since>2.0</since>
		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()))
						{
							// We can only do a CAS style delete if the client
							// didn't bork its delete request by sending the
							// wrong zero id rather than the advertised one.
							//
							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);
			}
		}