Example #1
0
		/// <exception cref="System.IO.IOException"></exception>
		private RefUpdate.Result UpdateImpl(RevWalk walk, RefUpdate.Store store)
		{
			RevObject newObj;
			RevObject oldObj;
			if (GetRefDatabase().IsNameConflicting(GetName()))
			{
				return RefUpdate.Result.LOCK_FAILURE;
			}
			try
			{
				if (!TryLock(true))
				{
					return RefUpdate.Result.LOCK_FAILURE;
				}
				if (expValue != null)
				{
					ObjectId o;
					o = oldValue != null ? oldValue : ObjectId.ZeroId;
					if (!AnyObjectId.Equals(expValue, o))
					{
						return RefUpdate.Result.LOCK_FAILURE;
					}
				}
				if (oldValue == null)
				{
					return store.Execute(RefUpdate.Result.NEW);
				}
				newObj = SafeParse(walk, newValue);
				oldObj = SafeParse(walk, oldValue);
				if (newObj == oldObj && !detachingSymbolicRef)
				{
					return store.Execute(RefUpdate.Result.NO_CHANGE);
				}
				if (newObj is RevCommit && oldObj is RevCommit)
				{
					if (walk.IsMergedInto((RevCommit)oldObj, (RevCommit)newObj))
					{
						return store.Execute(RefUpdate.Result.FAST_FORWARD);
					}
				}
				if (IsForceUpdate())
				{
					return store.Execute(RefUpdate.Result.FORCED);
				}
				return RefUpdate.Result.REJECTED;
			}
			finally
			{
				Unlock();
			}
		}