コード例 #1
0
ファイル: ObjectDatabase.cs プロジェクト: mjcheetham/dogged
        /// <summary>
        /// Read the metadata describing a git object.  If the actual object
        /// contents are not needed this may be more performant than reading
        /// the entire object, depending on the object database backend.
        /// </summary>
        /// <param name="id">The object ID to lookup</param>
        /// <exception cref="Dogged.NotFoundException">Thrown when the object is not found in the database</exception>
        /// <returns>An OdbObjectHeader on success</returns>
        public unsafe (long size, ObjectType type) ReadHeader(ObjectId id)
        {
            UIntPtr      size = UIntPtr.Zero;
            git_object_t type = git_object_t.GIT_OBJECT_INVALID;

            Ensure.ArgumentNotNull(id, "id");

            git_oid oid = id.ToNative();

            Ensure.NativeSuccess(() => libgit2.git_odb_read_header(out size, out type, nativeOdb, ref oid), this);
            Ensure.EnumDefined(typeof(ObjectType), (int)type, "object type");

            return(Ensure.CastToLong(size, "size"), (ObjectType)type);
        }
コード例 #2
0
        private unsafe ObjectDatabaseObject(git_odb_object *nativeObject)
        {
            Ensure.NativePointerNotNull(nativeObject);

            this.nativeObject = nativeObject;

            id = new LazyNative <ObjectId>(() => {
                git_oid *oid = libgit2.git_odb_object_id(nativeObject);
                Ensure.NativePointerNotNull(oid);
                return(ObjectId.FromNative(*oid));
            }, this);
            type = new LazyNative <ObjectType>(() => {
                git_object_t type = libgit2.git_odb_object_type(nativeObject);
                Ensure.EnumDefined(typeof(ObjectType), (int)type, "object type");
                return((ObjectType)type);
            }, this);
            size = new LazyNative <long>(() => {
                UIntPtr size = libgit2.git_odb_object_size(nativeObject);
                return(Ensure.CastToLong(size, "size"));
            }, this);
        }
コード例 #3
0
ファイル: libgit2.cs プロジェクト: mjcheetham/dogged
 public static extern unsafe int git_odb_read_header(out UIntPtr len_out, out git_object_t type, git_odb *odb, ref git_oid id);
コード例 #4
0
ファイル: libgit2.cs プロジェクト: mjcheetham/dogged
 public static extern unsafe int git_odb_write(ref git_oid id, git_odb *odb, byte *data, UIntPtr len, git_object_t type);
コード例 #5
0
ファイル: libgit2.cs プロジェクト: mjcheetham/dogged
 public static extern unsafe int git_object_lookup(out git_object *obj, git_repository *repo, ref git_oid id, git_object_t type);