Ejemplo n.º 1
0
        public virtual void testReadAllIncludingSymrefs()
        {
            ObjectId  masterId  = db.Resolve("refs/heads/master");
            RefUpdate updateRef = db.UpdateRef("refs/remotes/origin/master");

            updateRef.setNewObjectId(masterId);
            updateRef.setForceUpdate(true);
            updateRef.update();
            writeSymref("refs/remotes/origin/HEAD", "refs/remotes/origin/master");

            ObjectId r = db.Resolve("refs/remotes/origin/HEAD");

            Assert.AreEqual(masterId, r);

            IDictionary <string, global::GitSharp.Core.Ref> allRefs = db.getAllRefs();

            global::GitSharp.Core.Ref refHEAD = allRefs["refs/remotes/origin/HEAD"];
            Assert.IsNotNull(refHEAD);
            Assert.AreEqual(masterId, refHEAD.ObjectId);
            Assert.IsFalse(refHEAD.IsPeeled);
            Assert.IsNull(refHEAD.PeeledObjectId);

            global::GitSharp.Core.Ref refmaster = allRefs["refs/remotes/origin/master"];
            Assert.AreEqual(masterId, refmaster.ObjectId);
            Assert.IsFalse(refmaster.IsPeeled);
            Assert.IsNull(refmaster.PeeledObjectId);
        }
Ejemplo n.º 2
0
        private void Execute(ReceiveCommand cmd)
        {
            try
            {
                RefUpdate ru = db.UpdateRef(cmd.getRefName());
                ru.setRefLogIdent(getRefLogIdent());
                switch (cmd.getType())
                {
                case ReceiveCommand.Type.DELETE:
                    if (!ObjectId.ZeroId.Equals(cmd.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(cmd.getOldId());
                    }
                    ru.setForceUpdate(true);
                    Status(cmd, ru.delete(walk));
                    break;

                case ReceiveCommand.Type.CREATE:
                case ReceiveCommand.Type.UPDATE:
                case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:
                    ru.setForceUpdate(isAllowNonFastForwards());
                    ru.setExpectedOldObjectId(cmd.getOldId());
                    ru.setNewObjectId(cmd.getNewId());
                    ru.setRefLogMessage("push", true);
                    Status(cmd, ru.update(walk));
                    break;
                }
            }
            catch (IOException err)
            {
                cmd.setResult(ReceiveCommand.Result.REJECTED_OTHER_REASON, "lock error: " + err.Message);
            }
        }
Ejemplo n.º 3
0
        public void testReadSimplePackedRefSameRepo()
        {
            global::GitSharp.Core.Ref @ref = db.getRef("refs/heads/master");
            ObjectId pid = db.Resolve("refs/heads/master^");

            Assert.AreEqual(Storage.Packed, @ref.StorageFormat);
            RefUpdate updateRef = db.UpdateRef("refs/heads/master");

            updateRef.setNewObjectId(pid);
            updateRef.setForceUpdate(true);
            RefUpdate.RefUpdateResult update = updateRef.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.FORCED, update);

            @ref = db.getRef("refs/heads/master");
            Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
        }
Ejemplo n.º 4
0
        public void testReadSymRefToLoosePacked()
        {
            ObjectId  pid       = db.Resolve("refs/heads/master^");
            RefUpdate updateRef = db.UpdateRef("refs/heads/master");

            updateRef.setNewObjectId(pid);
            updateRef.setForceUpdate(true);
            RefUpdate.RefUpdateResult update = updateRef.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.FORCED, update); // internal

            writeSymref("HEAD", "refs/heads/master");
            global::GitSharp.Core.Ref @ref = db.getRef("HEAD");
            Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
            @ref = @ref.getTarget();
            Assert.AreEqual("refs/heads/master", @ref.Name);
            Assert.AreEqual(Storage.Loose, @ref.StorageFormat);
        }