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>2012-09-03 16:34:02 +0400
committernulltoken <emeric.fermas@gmail.com>2012-09-05 13:53:16 +0400
commit27378ee6e4d92d9fca5b462d5872edb9995c3b4b (patch)
treea4ebf626a16540e8a593c63cfbeb77e5dead6f81 /LibGit2Sharp/BranchCollection.cs
parentc8033399333f12d0e955812e341d23889a5974ca (diff)
Make Branches.Move() accept a Branch as its target
Diffstat (limited to 'LibGit2Sharp/BranchCollection.cs')
-rw-r--r--LibGit2Sharp/BranchCollection.cs22
1 files changed, 21 insertions, 1 deletions
diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs
index e4da587e..f265e474 100644
--- a/LibGit2Sharp/BranchCollection.cs
+++ b/LibGit2Sharp/BranchCollection.cs
@@ -215,7 +215,7 @@ namespace LibGit2Sharp
}
/// <summary>
- /// Rename an existing local branch with a new name.
+ /// Renames an existing local branch with a new name.
/// </summary>
/// <param name = "currentName">The current branch name.</param>
/// <param name = "newName">The new name the existing branch should bear.</param>
@@ -231,6 +231,26 @@ namespace LibGit2Sharp
return this[newName];
}
+ /// <summary>
+ /// Renames an existing local branch with a new name.
+ /// </summary>
+ /// <param name = "branch">The current local branch.</param>
+ /// <param name = "newName">The new name the existing branch should bear.</param>
+ /// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
+ /// <returns>A new <see cref="Branch"/>.</returns>
+ public virtual Branch Move(Branch branch, string newName, bool allowOverwrite = false)
+ {
+ Ensure.ArgumentNotNull(branch, "branch");
+ Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
+
+ if (branch.IsRemote)
+ {
+ throw new LibGit2SharpException(string.Format("Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
+ }
+
+ return Move(branch.Name, newName, allowOverwrite);
+ }
+
private static bool LooksLikeABranchName(string referenceName)
{
return referenceName == "HEAD" ||