Exemplo n.º 1
0
        private unsafe TreeEntry(Tree parent, git_tree_entry *nativeEntry)
        {
            Ensure.ArgumentNotNull(parent, "parent");
            Ensure.ArgumentNotNull(nativeEntry, "nativeEntry");

            this.parent      = parent;
            this.nativeEntry = nativeEntry;

            mode = new LazyNative <FileMode>(() => (FileMode)libgit2.git_tree_entry_filemode(nativeEntry), parent);

            id = new LazyNative <ObjectId>(() => {
                git_oid *oid = libgit2.git_tree_entry_id(nativeEntry);
                Ensure.NativePointerNotNull(oid);
                return(ObjectId.FromNative(*oid));
            }, parent);
            name = new LazyNative <string>(() => libgit2.git_tree_entry_name(nativeEntry), parent);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the index entry at the specified path.
        /// </summary>
        public unsafe TreeEntry this[string name]
        {
            get
            {
                Ensure.NotDisposed(NativeTree, "tree");
                Ensure.ArgumentNotNull(name, "name");

                git_tree_entry *entry = libgit2.git_tree_entry_byname(NativeTree, name);
                GC.KeepAlive(this);

                if (entry == null)
                {
                    throw new KeyNotFoundException(string.Format("there is no tree entry for path '{0}'", name));
                }

                return(TreeEntry.FromNative(this, entry));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the index entry at the specified index.
        /// </summary>
        public unsafe TreeEntry this[int position]
        {
            get
            {
                Ensure.NotDisposed(NativeTree, "tree");
                Ensure.ArgumentConformsTo(() => position >= 0, "position", "position must not be negative");

                git_tree_entry *entry = libgit2.git_tree_entry_byindex(NativeTree, (UIntPtr)position);
                GC.KeepAlive(this);

                if (entry == null)
                {
                    throw new IndexOutOfRangeException(string.Format("there is no tree entry at position {0}", position));
                }

                return(TreeEntry.FromNative(this, entry));
            }
        }
Exemplo n.º 4
0
 internal TreeEntryHandle(git_tree_entry *ptr, bool owned)
     : base((void *)ptr, owned)
 {
 }
Exemplo n.º 5
0
 internal unsafe static TreeEntry FromNative(Tree parent, git_tree_entry *nativeEntry)
 {
     return(new TreeEntry(parent, nativeEntry));
 }
Exemplo n.º 6
0
 public static extern unsafe string git_tree_entry_name(git_tree_entry *entry);
Exemplo n.º 7
0
 public static extern unsafe git_oid *git_tree_entry_id(git_tree_entry *entry);
Exemplo n.º 8
0
 public static extern unsafe uint git_tree_entry_filemode(git_tree_entry *entry);