Example #1
0
 public static extern int git_tag_create_lightweight(
     out GitOid oid,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
     GitObjectSafeHandle target,
     [MarshalAs(UnmanagedType.Bool)]
     bool force);
Example #2
0
 public static extern int git_note_create(
     out GitOid noteOid,
     RepositorySafeHandle repo,
     SignatureSafeHandle author,
     SignatureSafeHandle committer,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref,
     ref GitOid oid,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string note);
 public static extern int git_tag_create(
     out GitOid oid,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
     IntPtr target,
     GitSignature signature,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message,
     bool force);
Example #4
0
 internal static extern int git_tag_create(
     out GitOid oid,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
     GitObjectSafeHandle target,
     SignatureSafeHandle signature,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message,
     [MarshalAs(UnmanagedType.Bool)]
     bool force);
        public ObjectSafeWrapper(ObjectId id, Repository repo)
        {
            Ensure.ArgumentNotNull(id, "id");
            Ensure.ArgumentNotNull(repo, "repo");

            GitOid oid = id.Oid;
            int    res = NativeMethods.git_object_lookup(out objectPtr, repo.Handle, ref oid, GitObjectType.Any);

            Ensure.Success(res);
        }
        internal AbbreviatedObjectId(GitOid oid, int length)
            : base(oid)
        {
            if (length < MinHexSize || length > HexSize)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Expected length should be comprised between {0} and {1}.", MinHexSize, HexSize), "length");
            }

            Length = length;
        }
 public static extern int git_commit_create(
     out GitOid oid,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef,
     GitSignature author,
     GitSignature committer,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message,
     IntPtr tree,
     int parentCount,
     [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)][In] IntPtr[] parents);
Example #8
0
        public ObjectSafeWrapper(ObjectId id, Repository repo)
        {
            if (id == null)
            {
                return;
            }

            GitOid oid = id.Oid;
            int    res = NativeMethods.git_object_lookup(out objectPtr, repo.Handle, ref oid, GitObjectType.Any);

            Ensure.Success(res);
        }
Example #9
0
        /// <summary>
        ///   Inserts a <see cref="Blob"/> into the object database, created from the content of a file.
        /// </summary>
        /// <param name="path">Path to the file to create the blob from.</param>
        /// <returns>The created <see cref="Blob"/>.</returns>
        public Blob CreateBlob(string path)
        {
            Ensure.ArgumentNotNullOrEmptyString(path, "path");

            var oid = new GitOid();

            if (!repo.Info.IsBare && !Path.IsPathRooted(path))
            {
                Ensure.Success(NativeMethods.git_blob_create_fromfile(ref oid, repo.Handle, path));
            }
            else
            {
                Ensure.Success(NativeMethods.git_blob_create_fromdisk(ref oid, repo.Handle, path));
            }

            return repo.Lookup<Blob>(new ObjectId(oid));
        }
Example #10
0
 public static extern int git_reference_set_oid(ReferenceSafeHandle reference, ref GitOid id);
Example #11
0
 public static extern int git_treebuilder_insert(
     IntPtr entry_out,
     TreeBuilderSafeHandle builder,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string treeentry_name,
     ref GitOid id,
     uint attributes);
Example #12
0
            private static unsafe int ReadPrefix(
                out GitOid out_oid,
                out IntPtr buffer_p,
                out UIntPtr len_p,
                out Core.GitObjectType type_p,
                IntPtr backend,
                ref GitOid short_oid,
                UIntPtr len)
            {
                out_oid = default(GitOid);
                buffer_p = IntPtr.Zero;
                len_p = UIntPtr.Zero;
                type_p = Core.GitObjectType.Bad;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                if (odbBackend != null)
                {
                    byte[] oid;
                    Stream dataStream = null;
                    ObjectType objectType;

                    try
                    {
                        // The length of short_oid is described in characters (40 per full ID) vs. bytes (20)
                        // which is what we care about.
                        byte[] shortOidArray = new byte[(long)len >> 1];
                        Array.Copy(short_oid.Id, shortOidArray, shortOidArray.Length);

                        int toReturn = odbBackend.ReadPrefix(shortOidArray, out oid, out dataStream, out objectType);

                        if (0 == toReturn)
                        {
                            // Caller is expected to give us back a stream created with the Allocate() method.
                            UnmanagedMemoryStream memoryStream = dataStream as UnmanagedMemoryStream;

                            if (null == memoryStream)
                            {
                                return (int)GitErrorCode.Error;
                            }

                            out_oid.Id = oid;
                            len_p = new UIntPtr((ulong)memoryStream.Capacity);
                            type_p = objectType.ToGitObjectType();

                            memoryStream.Seek(0, SeekOrigin.Begin);
                            buffer_p = new IntPtr(memoryStream.PositionPointer);
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                    finally
                    {
                        if (null != dataStream)
                        {
                            dataStream.Dispose();
                        }
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #13
0
 internal static extern int git_index_write_tree(out GitOid treeOid, IndexSafeHandle index);
Example #14
0
 public static extern int git_tree_create_fromindex(out GitOid treeOid, IndexSafeHandle index);
            private static int FinalizeWrite(
                out GitOid oid_p,
                IntPtr stream)
            {
                oid_p = default(GitOid);

                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    byte[] computedObjectId;

                    try
                    {
                        int toReturn = odbBackendStream.FinalizeWrite(out computedObjectId);

                        if (0 == toReturn)
                        {
                            oid_p.Id = computedObjectId;
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #16
0
 internal static extern int git_stash_save(
     out GitOid id,
     RepositorySafeHandle repo,
     SignatureSafeHandle stasher,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message,
     StashOptions flags);
Example #17
0
 public static extern int git_reference_create_oid(
     out IntPtr reference,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name,
     ref GitOid oid,
     [MarshalAs(UnmanagedType.Bool)] bool force);
Example #18
0
 internal static extern int git_revwalk_next(out GitOid id, RevWalkerSafeHandle walker);
Example #19
0
 internal static extern int git_revwalk_push(RevWalkerSafeHandle walker, ref GitOid id);
Example #20
0
 internal static extern int git_revwalk_hide(RevWalkerSafeHandle walker, ref GitOid commit_id);
Example #21
0
 internal static extern int git_reference_set_target(out ReferenceSafeHandle ref_out, ReferenceSafeHandle reference, ref GitOid id);
Example #22
0
 internal static extern int git_note_remove(
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref,
     SignatureSafeHandle author,
     SignatureSafeHandle committer,
     ref GitOid oid);
Example #23
0
 public static extern int git_blob_create_fromfile(
     ref GitOid oid,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FilePathMarshaler))] FilePath path);
Example #24
0
 public static extern int git_reference_create_oid(out IntPtr reference, RepositorySafeHandle repo, string name, ref GitOid oid, bool force);
Example #25
0
 public static extern int git_object_lookup_prefix(out IntPtr obj, RepositorySafeHandle repo, ref GitOid id, uint len, GitObjectType type);
        /// <summary>
        ///   Handler for libgit2 update_tips callback. Converts values
        ///   received from libgit2 callback to more suitable types
        ///   and calls delegate provided by LibGit2Sharp consumer.
        /// </summary>
        /// <param name="str">IntPtr to string</param>
        /// <param name="oldId">Old reference ID</param>
        /// <param name="newId">New referene ID</param>
        /// <param name="data"></param>
        /// <returns></returns>
        private int GitUpdateTipsHandler(IntPtr str, ref GitOid oldId, ref GitOid newId, IntPtr data)
        {
            UpdateTipsHandler onUpdateTips = UpdateTips;
            int result = 0;

            if (onUpdateTips != null)
            {
                string refName = Utf8Marshaler.FromNative(str);
                result = onUpdateTips(refName, oldId, newId);
            }

            return result;
        }
Example #27
0
 public static extern int git_revwalk_next(out GitOid oid, RevWalkerSafeHandle walker);
Example #28
0
 public static extern int git_oid_cmp(ref GitOid a, ref GitOid b);
Example #29
0
 public static extern int git_tag_create_lightweight(out GitOid oid, RepositorySafeHandle repo, string name, IntPtr target, bool force);
Example #30
0
            private static unsafe int Read(
                out IntPtr buffer_p,
                out UIntPtr len_p,
                out GitObjectType type_p,
                IntPtr backend,
                ref GitOid oid)
            {
                buffer_p = IntPtr.Zero;
                len_p = UIntPtr.Zero;
                type_p = GitObjectType.Bad;

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                Stream dataStream = null;

                try
                {
                    ObjectType objectType;
                    int toReturn = odbBackend.Read(new ObjectId(oid), out dataStream, out objectType);

                    if (toReturn != 0)
                    {
                        return toReturn;
                    }

                    // Caller is expected to give us back a stream created with the Allocate() method.
                    var memoryStream = dataStream as UnmanagedMemoryStream;

                    if (memoryStream == null)
                    {
                        return (int)GitErrorCode.Error;
                    }

                    len_p = new UIntPtr((ulong)memoryStream.Capacity);
                    type_p = objectType.ToGitObjectType();

                    memoryStream.Seek(0, SeekOrigin.Begin);
                    buffer_p = new IntPtr(memoryStream.PositionPointer);

                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
                finally
                {
                    if (dataStream != null)
                    {
                        dataStream.Dispose();
                    }
                }

                return (int)GitErrorCode.Ok;
            }
Example #31
0
            private static unsafe int Read(
                out IntPtr buffer_p,
                out UIntPtr len_p,
                out Core.GitObjectType type_p,
                IntPtr backend,
                ref GitOid oid)
            {
                buffer_p = IntPtr.Zero;
                len_p = UIntPtr.Zero;
                type_p = Core.GitObjectType.Bad;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                if (odbBackend != null)
                {
                    Stream dataStream = null;
                    ObjectType objectType;

                    try
                    {
                        int toReturn = odbBackend.Read(oid.Id, out dataStream, out objectType);

                        if (0 == toReturn)
                        {
                            // Caller is expected to give us back a stream created with the Allocate() method.
                            UnmanagedMemoryStream memoryStream = dataStream as UnmanagedMemoryStream;

                            if (null == memoryStream)
                            {
                                return (int)GitErrorCode.Error;
                            }

                            len_p = new UIntPtr((ulong)memoryStream.Capacity);
                            type_p = objectType.ToGitObjectType();

                            memoryStream.Seek(0, SeekOrigin.Begin);
                            buffer_p = new IntPtr(memoryStream.PositionPointer);
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                    finally
                    {
                        if (null != dataStream)
                        {
                            dataStream.Dispose();
                        }
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #32
0
            private static unsafe int ReadPrefix(
                out GitOid out_oid,
                out IntPtr buffer_p,
                out UIntPtr len_p,
                out GitObjectType type_p,
                IntPtr backend,
                ref GitOid short_oid,
                UIntPtr len)
            {
                out_oid = default(GitOid);
                buffer_p = IntPtr.Zero;
                len_p = UIntPtr.Zero;
                type_p = GitObjectType.Bad;

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                Stream dataStream = null;

                try
                {
                    // The length of short_oid is described in characters (40 per full ID) vs. bytes (20)
                    // which is what we care about.
                    var oidLen = (int)len;

                    // Ensure we allocate enough space to cope with odd-sized prefix
                    int arraySize = (oidLen + 1) >> 1;
                    var shortOidArray = new byte[arraySize];
                    Array.Copy(short_oid.Id, shortOidArray, arraySize);

                    byte[] oid;
                    ObjectType objectType;

                    int toReturn = odbBackend.ReadPrefix(shortOidArray, oidLen, out oid, out dataStream, out objectType);

                    if (toReturn != 0)
                    {
                        return toReturn;
                    }

                    // Caller is expected to give us back a stream created with the Allocate() method.
                    var memoryStream = dataStream as UnmanagedMemoryStream;

                    if (memoryStream == null)
                    {
                        return (int)GitErrorCode.Error;
                    }

                    out_oid.Id = oid;
                    len_p = new UIntPtr((ulong)memoryStream.Capacity);
                    type_p = objectType.ToGitObjectType();

                    memoryStream.Seek(0, SeekOrigin.Begin);
                    buffer_p = new IntPtr(memoryStream.PositionPointer);
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
                finally
                {
                    if (null != dataStream)
                    {
                        dataStream.Dispose();
                    }
                }

                return (int)GitErrorCode.Ok;
            }
Example #33
0
            private static unsafe int Write(
                ref GitOid oid,
                IntPtr backend,
                IntPtr data,
                UIntPtr len,
                Core.GitObjectType type)
            {
                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    len.ToUInt64() < long.MaxValue)
                {
                    try
                    {
                        using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)data, (long)len.ToUInt64()))
                        {
                            byte[] finalOid;

                            int toReturn = odbBackend.Write(oid.Id, stream, (long)len.ToUInt64(), objectType, out finalOid);

                            if (0 == toReturn)
                            {
                                oid.Id = finalOid;
                            }

                            return toReturn;
                        }
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #34
0
 public static extern bool git_odb_exists(IntPtr db, ref GitOid id);
Example #35
0
 public static extern int git_object_lookup(out GitObjectSafeHandle obj, RepositorySafeHandle repo, ref GitOid id, GitObjectType type);
Example #36
0
            private unsafe static int ReadPrefix(
                out GitOid out_oid,
                out IntPtr buffer_p,
                out UIntPtr len_p,
                out GitObjectType type_p,
                IntPtr backend,
                ref GitOid short_oid,
                UIntPtr len)
            {
                out_oid = default(GitOid);
                buffer_p = IntPtr.Zero;
                len_p = UIntPtr.Zero;
                type_p = GitObjectType.Bad;

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                UnmanagedMemoryStream memoryStream = null;

                try
                {
                    var shortSha = ObjectId.ToString(short_oid.Id, (int) len);

                    ObjectId oid;
                    ObjectType objectType;

                    int toReturn = odbBackend.ReadPrefix(shortSha, out oid, out memoryStream, out objectType);

                    if (toReturn != 0)
                    {
                        return toReturn;
                    }

                    if (memoryStream == null)
                    {
                        return (int)GitErrorCode.Error;
                    }

                    out_oid.Id = oid.RawId;
                    len_p = new UIntPtr((ulong)memoryStream.Capacity);
                    type_p = objectType.ToGitObjectType();

                    memoryStream.Seek(0, SeekOrigin.Begin);
                    buffer_p = new IntPtr(memoryStream.PositionPointer);
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
                finally
                {
                    if (memoryStream != null)
                    {
                        memoryStream.Dispose();
                    }
                }

                return (int)GitErrorCode.Ok;
            }
Example #37
0
 public static extern int git_commit_create(out GitOid oid, RepositorySafeHandle repo, string updateRef, GitSignature author, GitSignature committer, string message, IntPtr tree, int parentCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)] [In] IntPtr[] parents);
Example #38
0
            private static int ReadHeader(
                out UIntPtr len_p,
                out GitObjectType type_p,
                IntPtr backend,
                ref GitOid oid)
            {
                len_p = UIntPtr.Zero;
                type_p = GitObjectType.Bad;

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                try
                {
                    int length;
                    ObjectType objectType;
                    int toReturn = odbBackend.ReadHeader(new ObjectId(oid), out length, out objectType);

                    if (toReturn != 0)
                    {
                        return toReturn;
                    }

                    len_p = new UIntPtr((uint)length);
                    type_p = objectType.ToGitObjectType();
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }

                return (int)GitErrorCode.Ok;
            }
Example #39
0
 public static extern int git_treebuilder_write(out GitOid oid, RepositorySafeHandle repo, TreeBuilderSafeHandle bld);
Example #40
0
            private static unsafe int Write(
                IntPtr backend,
                ref GitOid oid,
                IntPtr data,
                UIntPtr len,
                GitObjectType type)
            {
                long length = ConverToLong(len);

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                try
                {
                    using (var stream = new UnmanagedMemoryStream((byte*)data, length))
                    {
                        return odbBackend.Write(new ObjectId(oid), stream, length, type.ToObjectType());
                    }
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
            }
Example #41
0
        /// <summary>
        /// Handler for libgit2 update_tips callback. Converts values
        /// received from libgit2 callback to more suitable types
        /// and calls delegate provided by LibGit2Sharp consumer.
        /// </summary>
        /// <param name="str">IntPtr to string</param>
        /// <param name="oldId">Old reference ID</param>
        /// <param name="newId">New referene ID</param>
        /// <param name="data">IntPtr to optional payload passed back to the callback.</param>
        /// <returns>0 on success; a negative value to abort the process.</returns>
        private int GitUpdateTipsHandler(IntPtr str, ref GitOid oldId, ref GitOid newId, IntPtr data)
        {
            UpdateTipsHandler onUpdateTips = UpdateTips;
            bool shouldContinue = true;

            if (onUpdateTips != null)
            {
                string refName = LaxUtf8Marshaler.FromNative(str);
                shouldContinue = onUpdateTips(refName, oldId, newId);
            }

            return Proxy.ConvertResultToCancelFlag(shouldContinue);
        }
Example #42
0
            private static int ReadStream(
                out IntPtr stream_out,
                IntPtr backend,
                ref GitOid oid)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                try
                {
                    OdbBackendStream stream;
                    int toReturn = odbBackend.ReadStream(new ObjectId(oid), out stream);

                    if (toReturn == 0)
                    {
                        stream_out = stream.GitOdbBackendStreamPointer;
                    }

                    return toReturn;
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
            }
Example #43
0
 public static extern int git_oid_cmp(ref GitOid a, ref GitOid b);
Example #44
0
            private static bool Exists(
                IntPtr backend,
                ref GitOid oid)
            {
                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return false; // Weird
                }

                try
                {
                    return odbBackend.Exists(new ObjectId(oid));
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return false;
                }
            }
Example #45
0
 public static extern int git_reference_set_oid(IntPtr reference, ref GitOid id);
Example #46
0
            private static int ExistsPrefix(
                ref GitOid found_oid,
                IntPtr backend,
                ref GitOid short_oid,
                UIntPtr len)
            {
                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                try
                {
                    ObjectId found;
                    var shortSha = ObjectId.ToString(short_oid.Id, (int)len);

                    found_oid.Id = ObjectId.Zero.RawId;
                    int result = odbBackend.ExistsPrefix(shortSha, out found);

                    if (result == (int) GitErrorCode.Ok)
                    {
                        found_oid.Id = found.RawId;
                    }

                    return result;
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
            }
Example #47
0
 public static extern int git_revwalk_push(RevWalkerSafeHandle walker, ref GitOid oid);
Example #48
0
        //TODO: Convert to a ParentEnumerator
        private List<Commit> RetrieveParentsOfCommit(GitOid oid)
        {
            IntPtr obj;
            var res = NativeMethods.git_object_lookup(out obj, repo.Handle, ref oid, GitObjectType.Commit);
            Ensure.Success(res);

            try
            {
                parents = new List<Commit>();

                uint parentsCount = NativeMethods.git_commit_parentcount(obj);

                for (uint i = 0; i < parentsCount; i++)
                {
                    IntPtr parentCommit;
                    res = NativeMethods.git_commit_parent(out parentCommit, obj, i);
                    Ensure.Success(res);
                    parents.Add((Commit)CreateFromPtr(parentCommit, ObjectIdOf(parentCommit), repo));
                }
            }
            finally
            {
                NativeMethods.git_object_close(obj);
            }

            return parents;
        }
Example #49
0
 public static extern int git_tree_create_fromindex(out GitOid treeOid, IndexSafeHandle index);
Example #50
0
 public static extern int git_tag_create(out GitOid oid, RepositorySafeHandle repo, string name, IntPtr target, GitSignature signature, string message, bool force);
Example #51
0
            private static int FinalizeWrite(
                IntPtr stream,
                ref GitOid oid)
            {
                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    try
                    {
                        return odbBackendStream.FinalizeWrite(new ObjectId(oid));
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #52
0
 public static extern int git_merge_base(
     out GitOid mergeBase,
     RepositorySafeHandle repo,
     GitObjectSafeHandle one,
     GitObjectSafeHandle two);
Example #53
0
            private static bool Exists(
                IntPtr backend,
                ref GitOid oid)
            {
                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                if (odbBackend != null)
                {
                    try
                    {
                        return odbBackend.Exists(oid.Id);
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return false;
            }
Example #54
0
 public static extern int git_object_lookup_prefix(out IntPtr obj, RepositorySafeHandle repo, ref GitOid id, uint len, GitObjectType type);
Example #55
0
            private static int ReadHeader(
                out UIntPtr len_p,
                out Core.GitObjectType type_p,
                IntPtr backend,
                ref GitOid oid)
            {
                len_p = UIntPtr.Zero;
                type_p = Core.GitObjectType.Bad;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                if (odbBackend != null)
                {
                    int length;
                    ObjectType objectType;

                    try
                    {
                        int toReturn = odbBackend.ReadHeader(oid.Id, out length, out objectType);

                        if (0 == toReturn)
                        {
                            len_p = new UIntPtr((uint)length);
                            type_p = objectType.ToGitObjectType();
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #56
0
 public static extern int git_note_read(
     out NoteSafeHandle note,
     RepositorySafeHandle repo,
     [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref,
     ref GitOid oid);
Example #57
0
            private static int ReadStream(
                out IntPtr stream_out,
                IntPtr backend,
                ref GitOid oid)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                if (odbBackend != null)
                {
                    OdbBackendStream stream;

                    try
                    {
                        int toReturn = odbBackend.ReadStream(oid.Id, out stream);

                        if (0 == toReturn)
                        {
                            stream_out = stream.GitOdbBackendStreamPointer;
                        }

                        return toReturn;
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return (int)GitErrorCode.Error;
            }
Example #58
0
 public static extern int git_odb_exists(ObjectDatabaseSafeHandle odb, ref GitOid id);
Example #59
0
                private int CallbackMethod(byte[] oid)
                {
                    GitOid gitOid = new GitOid();
                    gitOid.Id = oid;

                    return cb(ref gitOid, data);
                }
Example #60
0
 internal static extern int git_graph_ahead_behind(out UIntPtr ahead, out UIntPtr behind, RepositorySafeHandle repo, ref GitOid one, ref GitOid two);