public virtual void TestDirCacheMatchingId()
        {
            FilePath f   = WriteTrashFile("file", "content");
            Git      git = new Git(db);

            WriteTrashFile("file", "content");
            FsTick(f);
            git.Add().AddFilepattern("file").Call();
            DirCacheEntry    dce = db.ReadDirCache().GetEntry("file");
            TreeWalk         tw  = new TreeWalk(db);
            FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
                                                                                )db.GetConfig()).Get(WorkingTreeOptions.KEY));

            tw.AddTree(fti);
            DirCacheIterator dci = new DirCacheIterator(db.ReadDirCache());

            tw.AddTree(dci);
            fti.SetDirCacheIterator(tw, 1);
            while (tw.Next() && !tw.PathString.Equals("file"))
            {
            }
            //
            NUnit.Framework.Assert.AreEqual(WorkingTreeIterator.MetadataDiff.EQUAL, fti.CompareMetadata
                                                (dce));
            ObjectId fromRaw = ObjectId.FromRaw(fti.IdBuffer, fti.IdOffset);

            NUnit.Framework.Assert.AreEqual("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", fromRaw
                                            .GetName());
            NUnit.Framework.Assert.IsFalse(fti.IsModified(dce, false));
        }
Esempio n. 2
0
		public virtual void TestIsModifiedFileSmudged()
		{
			FilePath f = WriteTrashFile("file", "content");
			Git git = new Git(db);
			// The idea of this test is to check the smudged handling
			// Hopefully fsTick will make sure our entry gets smudged
			FsTick(f);
			WriteTrashFile("file", "content");
			git.Add().AddFilepattern("file").Call();
			WriteTrashFile("file", "conten2");
			DirCacheEntry dce = db.ReadDirCache().GetEntry("file");
			FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
				)db.GetConfig()).Get(WorkingTreeOptions.KEY));
			while (!fti.EntryPathString.Equals("file"))
			{
				fti.Next(1);
			}
			// If the fsTick trick does not work we could skip the compareMetaData
			// test and hope that we are usually testing the intended code path.
			NUnit.Framework.Assert.AreEqual(WorkingTreeIterator.MetadataDiff.SMUDGED, fti.CompareMetadata
				(dce));
			NUnit.Framework.Assert.IsTrue(fti.IsModified(dce, false));
		}
Esempio n. 3
0
		public virtual void TestDirCacheMatchingId()
		{
			FilePath f = WriteTrashFile("file", "content");
			Git git = new Git(db);
			WriteTrashFile("file", "content");
			FsTick(f);
			git.Add().AddFilepattern("file").Call();
			DirCacheEntry dce = db.ReadDirCache().GetEntry("file");
			TreeWalk tw = new TreeWalk(db);
			FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
				)db.GetConfig()).Get(WorkingTreeOptions.KEY));
			tw.AddTree(fti);
			DirCacheIterator dci = new DirCacheIterator(db.ReadDirCache());
			tw.AddTree(dci);
			fti.SetDirCacheIterator(tw, 1);
			while (tw.Next() && !tw.PathString.Equals("file"))
			{
			}
			//
			NUnit.Framework.Assert.AreEqual(WorkingTreeIterator.MetadataDiff.EQUAL, fti.CompareMetadata
				(dce));
			ObjectId fromRaw = ObjectId.FromRaw(fti.IdBuffer, fti.IdOffset);
			NUnit.Framework.Assert.AreEqual("6b584e8ece562ebffc15d38808cd6b98fc3d97ea", fromRaw
				.GetName());
			NUnit.Framework.Assert.IsFalse(fti.IsModified(dce, false));
		}
        public virtual void TestIsModifiedFileSmudged()
        {
            FilePath f   = WriteTrashFile("file", "content");
            Git      git = new Git(db);

            // The idea of this test is to check the smudged handling
            // Hopefully fsTick will make sure our entry gets smudged
            FsTick(f);
            WriteTrashFile("file", "content");
            git.Add().AddFilepattern("file").Call();
            WriteTrashFile("file", "conten2");
            DirCacheEntry    dce = db.ReadDirCache().GetEntry("file");
            FileTreeIterator fti = new FileTreeIterator(trash, db.FileSystem, ((FileBasedConfig
                                                                                )db.GetConfig()).Get(WorkingTreeOptions.KEY));

            while (!fti.EntryPathString.Equals("file"))
            {
                fti.Next(1);
            }
            // If the fsTick trick does not work we could skip the compareMetaData
            // test and hope that we are usually testing the intended code path.
            NUnit.Framework.Assert.AreEqual(WorkingTreeIterator.MetadataDiff.SMUDGED, fti.CompareMetadata
                                                (dce));
            NUnit.Framework.Assert.IsTrue(fti.IsModified(dce, false));
        }