Example #1
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 #2
0
 /// <summary>
 /// Returns the <see cref="Id"/>, a <see cref="String"/> representation of the current <see cref="GitObject"/>.
 /// </summary>
 /// <returns>The <see cref="Id"/> that represents the current <see cref="GitObject"/>.</returns>
 public override string ToString()
 {
     return(Id.ToString());
 }