diff options
author | yorah <yoram.harmelin@gmail.com> | 2012-08-29 20:05:47 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-08-29 22:14:31 +0400 |
commit | eb304fb0c92df60339836b962a96a3d43f48d7f7 (patch) | |
tree | b49ad08201406d354304010c5f17d241d1b99c3c /LibGit2Sharp/Reference.cs | |
parent | 8fa70ffce8bca7ff66fe4b84293d14b66bbed29f (diff) |
Make retrieval of error message thread-safe
Fix #203
Diffstat (limited to 'LibGit2Sharp/Reference.cs')
-rw-r--r-- | LibGit2Sharp/Reference.cs | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/LibGit2Sharp/Reference.cs b/LibGit2Sharp/Reference.cs index 0c78aef5..68997841 100644 --- a/LibGit2Sharp/Reference.cs +++ b/LibGit2Sharp/Reference.cs @@ -21,17 +21,17 @@ namespace LibGit2Sharp internal static T BuildFromPtr<T>(ReferenceSafeHandle handle, Repository repo) where T : Reference { - GitReferenceType type = NativeMethods.git_reference_type(handle); - string name = NativeMethods.git_reference_name(handle); + GitReferenceType type = Proxy.git_reference_type(handle); + string name = Proxy.git_reference_name(handle); Reference reference; switch (type) { case GitReferenceType.Symbolic: - string targetIdentifier = NativeMethods.git_reference_target(handle); + string targetIdentifier = Proxy.git_reference_target(handle); - using (ReferenceSafeHandle resolvedHandle = PeelToDirectReference(handle)) + using (ReferenceSafeHandle resolvedHandle = Proxy.git_reference_resolve(handle)) { if (resolvedHandle == null) { @@ -45,7 +45,7 @@ namespace LibGit2Sharp } case GitReferenceType.Oid: - ObjectId targetOid = NativeMethods.git_reference_oid(handle).MarshalAsObjectId(); + ObjectId targetOid = Proxy.git_reference_oid(handle); var targetBuilder = new Lazy<GitObject>(() => repo.Lookup(targetOid)); reference = new DirectReference(targetBuilder) { CanonicalName = name, TargetIdentifier = targetOid.Sha }; @@ -58,21 +58,6 @@ namespace LibGit2Sharp return reference as T; } - private static ReferenceSafeHandle PeelToDirectReference(ReferenceSafeHandle handle) - { - ReferenceSafeHandle resolvedHandle; - int res = NativeMethods.git_reference_resolve(out resolvedHandle, handle); - - if (res == (int)GitErrorCode.NotFound) - { - return null; - } - - Ensure.Success(res); - - return resolvedHandle; - } - /// <summary> /// Recursively peels the target of the reference until a direct reference is encountered. /// </summary> |