From c37d818160608e337a7acaf7fbe11a55f124b8e8 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sat, 25 Feb 2012 19:12:02 +0100 Subject: Add RemoteCollection.Create() --- LibGit2Sharp/RemoteCollection.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'LibGit2Sharp/RemoteCollection.cs') diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index e4c23688..d2950b6f 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -71,5 +71,29 @@ namespace LibGit2Sharp { return GetEnumerator(); } + + /// + /// Creates a with the specified name and for the repository at the specified location + /// + /// The name of the remote to create. + /// The location of the repository. + /// A new . + public Remote Create(string name, string url) + { + Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNull(url, "url"); + + RemoteSafeHandle handle; + int res = NativeMethods.git_remote_new(out handle, repository.Handle, url, name); + Ensure.Success(res); + + using (handle) + { + res = NativeMethods.git_remote_save(handle); + Ensure.Success(res); + + return Remote.CreateFromPtr(handle); + } + } } } -- cgit v1.2.3