diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-12-20 11:07:17 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2013-12-21 12:31:38 +0400 |
commit | e5a6ad54991ff19aa086f2994b92ebb7c6749e57 (patch) | |
tree | d8e60f9f04bf7925aa9e319ecd015fafc0f998b4 /LibGit2Sharp/OdbBackend.cs | |
parent | a342d689be3cb29c5556d7e2033cf961daaeb71f (diff) |
Simplify OdbBackend.ReadPrefix() implementation
Diffstat (limited to 'LibGit2Sharp/OdbBackend.cs')
-rw-r--r-- | LibGit2Sharp/OdbBackend.cs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/LibGit2Sharp/OdbBackend.cs b/LibGit2Sharp/OdbBackend.cs index 03e9f3a5..1862d26b 100644 --- a/LibGit2Sharp/OdbBackend.cs +++ b/LibGit2Sharp/OdbBackend.cs @@ -62,9 +62,8 @@ namespace LibGit2Sharp /// Requests that this backend read an object. The object ID may not be complete (may be a prefix). /// </summary> public abstract int ReadPrefix( - byte[] shortOid, - int prefixLen, - out byte[] oid, + string shortSha, + out ObjectId oid, out Stream data, out ObjectType objectType); @@ -298,19 +297,12 @@ namespace LibGit2Sharp 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; + var shortSha = ObjectId.ToString(short_oid.Id, (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; + ObjectId oid; ObjectType objectType; - int toReturn = odbBackend.ReadPrefix(shortOidArray, oidLen, out oid, out dataStream, out objectType); + int toReturn = odbBackend.ReadPrefix(shortSha, out oid, out dataStream, out objectType); if (toReturn != 0) { @@ -325,7 +317,7 @@ namespace LibGit2Sharp return (int)GitErrorCode.Error; } - out_oid.Id = oid; + out_oid.Id = oid.RawId; len_p = new UIntPtr((ulong)memoryStream.Capacity); type_p = objectType.ToGitObjectType(); |