예제 #1
0
        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));
        }
예제 #2
0
파일: Tree.cs 프로젝트: zvirja/libgit2sharp
        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)));
            }
        }