internal unsafe TreeEntry(TreeEntryHandle entry, ObjectId parentTreeId, Repository repo, string parentPath) { this.parentTreeId = parentTreeId; this.repo = repo; targetOid = Proxy.git_tree_entry_id(entry); GitObjectType treeEntryTargetType = Proxy.git_tree_entry_type(entry); TargetType = treeEntryTargetType.ToTreeEntryTargetType(); target = new Lazy <GitObject>(RetrieveTreeEntryTarget); Mode = Proxy.git_tree_entry_attributes(entry); Name = Proxy.git_tree_entry_name(entry); path = new Lazy <string>(() => Tree.CombinePath(parentPath, Name)); }
private unsafe TreeEntry RetrieveFromPath(string relativePath) { if (string.IsNullOrEmpty(relativePath)) { return(null); } using (TreeEntryHandle treeEntry = Proxy.git_tree_entry_bypath(repo.Handle, Id, relativePath)) { if (treeEntry == null) { return(null); } string filename = relativePath.Split('/').Last(); string parentPath = relativePath.Substring(0, relativePath.Length - filename.Length); return(new TreeEntry(treeEntry, Id, repo, Tree.CombinePath(path, parentPath))); } }