/// <exception cref="System.IO.IOException"></exception>
        protected internal override bool TryLock(bool deref)
        {
            Ref dst = GetRef();

            if (deref)
            {
                dst = dst.GetLeaf();
            }
            string name = dst.GetName();

            Lock = new LockFile(database.FileFor(name), GetRepository().FileSystem);
            if (Lock.Lock())
            {
                dst = database.GetRef(name);
                SetOldObjectId(dst != null ? dst.GetObjectId() : null);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public virtual void TestGetRef_DiscoversModifiedLoose()
        {
            IDictionary <string, Ref> all;

            WriteLooseRef("refs/heads/master", A);
            all = refdir.GetRefs(RefDatabase.ALL);
            NUnit.Framework.Assert.AreEqual(A, all.Get(Constants.HEAD).GetObjectId());
            WriteLooseRef("refs/heads/master", B);
            Ref master = refdir.GetRef("refs/heads/master");

            NUnit.Framework.Assert.AreEqual(B, master.GetObjectId());
        }