private DirCacheEntry toEntry(int stage, TreeWalk.TreeWalk tw) { DirCacheEntry e = new DirCacheEntry(tw.getRawPath(), stage); AbstractTreeIterator i; i = tw.getTree<AbstractTreeIterator>(0, typeof(AbstractTreeIterator)); e.setFileMode(tw.getFileMode(0)); e.setObjectIdFromRaw(i.idBuffer(), i.idOffset()); return e; }
private DirCacheEntry MakeEntry(String path, FileMode mode, String content) { DirCacheEntry ent = new DirCacheEntry(path); ent.setFileMode(mode); byte[] contentBytes = Constants.encode(content); ent.setObjectId(new ObjectWriter(db).ComputeBlobSha1(contentBytes.Length, new MemoryStream(contentBytes))); return ent; }
public void testBuildOneFile_FinishWriteCommit() { string path = "a-File-path"; var mode = GitSharp.FileMode.RegularFile; long lastModified = 1218123387057L; int Length = 1342; DirCacheEntry entOrig; DirCache dc = DirCache.Lock(db); DirCacheBuilder b = dc.builder(); Assert.IsNotNull(b); entOrig = new DirCacheEntry(path); entOrig.setFileMode(mode); entOrig.setLastModified(lastModified); entOrig.setLength(Length); Assert.AreNotSame(path, entOrig.getPathString()); Assert.AreEqual(path, entOrig.getPathString()); Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId()); Assert.AreEqual(mode.Bits, entOrig.getRawMode()); Assert.AreEqual(0, entOrig.getStage()); Assert.AreEqual(lastModified, entOrig.getLastModified()); Assert.AreEqual(Length, entOrig.getLength()); Assert.IsFalse(entOrig.isAssumeValid()); b.add(entOrig); b.finish(); Assert.AreEqual(1, dc.getEntryCount()); Assert.AreSame(entOrig, dc.getEntry(0)); dc.write(); Assert.IsTrue(dc.commit()); dc = DirCache.read(db); Assert.AreEqual(1, dc.getEntryCount()); DirCacheEntry entRead = dc.getEntry(0); Assert.AreNotSame(entOrig, entRead); Assert.AreEqual(path, entRead.getPathString()); Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId()); Assert.AreEqual(mode.Bits, entOrig.getRawMode()); Assert.AreEqual(0, entOrig.getStage()); Assert.AreEqual(lastModified, entOrig.getLastModified()); Assert.AreEqual(Length, entOrig.getLength()); Assert.IsFalse(entOrig.isAssumeValid()); }
private DirCacheEntry makeEntry(string path, FileMode mode) { byte[] pathBytes = Constants.encode(path); DirCacheEntry ent = new DirCacheEntry(path); ent.setFileMode(mode); ent.setObjectId(new ObjectWriter(db).ComputeBlobSha1(pathBytes.Length, new MemoryStream(pathBytes))); return ent; }
private static DirCacheEntry ToEntry(int stage, TreeWalk.TreeWalk tw) { var e = new DirCacheEntry(tw.getRawPath(), stage); var iterator = tw.getTree<AbstractTreeIterator>(0, typeof(AbstractTreeIterator)); e.setFileMode(tw.getFileMode(0)); e.setObjectIdFromRaw(iterator.idBuffer(), iterator.idOffset()); return e; }
private void Add(int tree, int stage) { AbstractTreeIterator i = GetTree(tree); if (i != null) { if (FileMode.Tree.Equals(_tw.getRawMode(tree))) { _builder.addTree(_tw.getRawPath(), stage, Db, _tw .getObjectId(tree)); } else { DirCacheEntry e = new DirCacheEntry(_tw.getRawPath(), stage); e.setObjectIdFromRaw(i.idBuffer(), i.idOffset()); e.setFileMode(_tw.getFileMode(tree)); _builder.add(e); } } }