Ejemplo n.º 1
0
        /// <summary>
        /// Lookup and return the git object in the repository as specified
        /// by the given ID.
        /// </summary>
        /// <param name="id">The object id to lookup</param>
        /// <returns>The Git object specified by the given ID</returns>
        public unsafe T Lookup <T>(ObjectId id) where T : GitObject
        {
            Ensure.ArgumentNotNull(id, "id");

            git_oid oid = id.ToNative();

            if (typeof(T) == typeof(Commit))
            {
                git_commit *obj = null;
                Ensure.NativeSuccess(() => libgit2.git_commit_lookup(out obj, repository.NativeRepository, ref oid), repository);
                return((T)(object)Commit.FromNative(obj, id));
            }
            else if (typeof(T) == typeof(Tree))
            {
                git_tree *obj = null;
                Ensure.NativeSuccess(() => libgit2.git_tree_lookup(out obj, repository.NativeRepository, ref oid), repository);
                return((T)(object)Tree.FromNative(obj, id));
            }
            else if (typeof(T) == typeof(Blob))
            {
                git_blob *obj = null;
                Ensure.NativeSuccess(() => libgit2.git_blob_lookup(out obj, repository.NativeRepository, ref oid), repository);
                return((T)(object)Blob.FromNative(obj, id));
            }
            else if (typeof(T) == typeof(GitObject))
            {
                return((T)(object)Lookup(id));
            }

            throw new InvalidOperationException("unknown object type");
        }
Ejemplo n.º 2
0
 public static extern unsafe int git_filter_list_load(
     out git_filter_list *filters,
     git_repository *repo,
     git_blob *blob,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = Utf8Marshaler.ToNative, MarshalTypeRef = typeof(Utf8Marshaler))] string path,
     git_filter_mode_t mode,
     uint flags);
Ejemplo n.º 3
0
 internal unsafe static Blob FromNative(git_blob *nativeBlob, ObjectId id)
 {
     return(new Blob(nativeBlob, id));
 }
Ejemplo n.º 4
0
 private unsafe Blob(git_blob *nativeBlob, ObjectId id) :
     base((git_object *)nativeBlob, id)
 {
     rawSize  = new LazyNative <long>(() => libgit2.git_blob_rawsize(nativeBlob), this);
     isBinary = new LazyNative <bool>(() => libgit2.git_blob_is_binary(nativeBlob) == 0 ? false : true, this);
 }
Ejemplo n.º 5
0
 public static extern unsafe long git_blob_rawsize(git_blob *blob);
Ejemplo n.º 6
0
 public static extern unsafe byte *git_blob_rawcontent(git_blob *blob);
Ejemplo n.º 7
0
 public static extern unsafe int git_blob_lookup(out git_blob *blob, git_repository *repo, ref git_oid id);
Ejemplo n.º 8
0
 public static extern unsafe int git_blob_is_binary(git_blob *blob);
Ejemplo n.º 9
0
 public static extern unsafe int git_blob_filter(
     git_buf content,
     git_blob *blob,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = Utf8Marshaler.ToNative, MarshalTypeRef = typeof(Utf8Marshaler))] string path,
     git_blob_filter_options *options);
Ejemplo n.º 10
0
 public static extern unsafe int git_filter_list_apply_to_blob(git_buf outputBuffer, git_filter_list *filters, git_blob *blob);