Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2013-04-29 21:27:05 +0400
committernulltoken <emeric.fermas@gmail.com>2013-04-29 21:27:05 +0400
commit023eaf4ff4346140acb93797b3e9984e4434b1b2 (patch)
tree71482a6541b927aef757716c9481ad3bdb9b7e0d /LibGit2Sharp/RepositoryExtensions.cs
parent1465bf31cdfcf59bceab42bb0e8d0543b02503dc (diff)
Prevent repo.Lookup() to accept GitLink as a target type
Diffstat (limited to 'LibGit2Sharp/RepositoryExtensions.cs')
-rw-r--r--LibGit2Sharp/RepositoryExtensions.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/LibGit2Sharp/RepositoryExtensions.cs b/LibGit2Sharp/RepositoryExtensions.cs
index c653e9fe..ae62fab2 100644
--- a/LibGit2Sharp/RepositoryExtensions.cs
+++ b/LibGit2Sharp/RepositoryExtensions.cs
@@ -21,6 +21,8 @@ namespace LibGit2Sharp
/// <returns></returns>
public static T Lookup<T>(this IRepository repository, string objectish) where T : GitObject
{
+ EnsureNoGitLink<T>();
+
return (T)repository.Lookup(objectish, GitObject.TypeToTypeMap[typeof (T)]);
}
@@ -33,9 +35,21 @@ namespace LibGit2Sharp
/// <returns></returns>
public static T Lookup<T>(this IRepository repository, ObjectId id) where T : GitObject
{
+ EnsureNoGitLink<T>();
+
return (T)repository.Lookup(id, GitObject.TypeToTypeMap[typeof(T)]);
}
+ private static void EnsureNoGitLink<T>() where T : GitObject
+ {
+ if (typeof(T) != typeof(GitLink))
+ {
+ return;
+ }
+
+ throw new ArgumentException("A GitObject of type 'GitLink' cannot be looked up.");
+ }
+
/// <summary>
/// Creates a lightweight tag with the specified name. This tag will point at the commit pointed at by the <see cref = "Repository.Head" />.
/// </summary>