示例#1
0
        public virtual void TestlogAllRefUpdates()
        {
            long commitTime = 1154236443000L;
            int  tz         = -4 * 60;

            // check that there are no entries in the reflog and turn off writing
            // reflogs
            NUnit.Framework.Assert.AreEqual(0, db.GetReflogReader(Constants.HEAD).GetReverseEntries
                                                ().Count);
            FileBasedConfig cfg = ((FileBasedConfig)db.GetConfig());

            cfg.SetBoolean("core", null, "logallrefupdates", false);
            cfg.Save();
            // do one commit and check that reflog size is 0: no reflogs should be
            // written
            Commit("A Commit\n", new PersonIdent(author, commitTime, tz), new PersonIdent(committer
                                                                                          , commitTime, tz));
            commitTime += 60 * 1000;
            NUnit.Framework.Assert.IsTrue(db.GetReflogReader(Constants.HEAD).GetReverseEntries
                                              ().Count == 0, "Reflog for HEAD still contain no entry");
            // set the logAllRefUpdates parameter to true and check it
            cfg.SetBoolean("core", null, "logallrefupdates", true);
            cfg.Save();
            NUnit.Framework.Assert.IsTrue(cfg.Get(CoreConfig.KEY).IsLogAllRefUpdates());
            // do one commit and check that reflog size is increased to 1
            Commit("A Commit\n", new PersonIdent(author, commitTime, tz), new PersonIdent(committer
                                                                                          , commitTime, tz));
            commitTime += 60 * 1000;
            NUnit.Framework.Assert.IsTrue(db.GetReflogReader(Constants.HEAD).GetReverseEntries
                                              ().Count == 1, "Reflog for HEAD should contain one entry");
            // set the logAllRefUpdates parameter to false and check it
            cfg.SetBoolean("core", null, "logallrefupdates", false);
            cfg.Save();
            NUnit.Framework.Assert.IsFalse(cfg.Get(CoreConfig.KEY).IsLogAllRefUpdates());
            // do one commit and check that reflog size is 2
            Commit("A Commit\n", new PersonIdent(author, commitTime, tz), new PersonIdent(committer
                                                                                          , commitTime, tz));
            NUnit.Framework.Assert.IsTrue(db.GetReflogReader(Constants.HEAD).GetReverseEntries
                                              ().Count == 2, "Reflog for HEAD should contain two entries");
        }