@@ -117,6 +117,31 @@ public virtual Branch Add(string name, string committish)
117117 return Add ( name , committish , false ) ;
118118 }
119119
120+ /// <summary>
121+ /// Create a new local branch with the specified name
122+ /// </summary>
123+ /// <param name="name">The name of the branch.</param>
124+ /// <param name="commit">The target commit.</param>
125+ /// <returns>A new <see cref="Branch"/>.</returns>
126+ public virtual Branch Add ( string name , Commit commit )
127+ {
128+ return Add ( name , commit , false ) ;
129+ }
130+
131+ /// <summary>
132+ /// Create a new local branch with the specified name
133+ /// </summary>
134+ /// <param name="name">The name of the branch.</param>
135+ /// <param name="commit">The target commit.</param>
136+ /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
137+ /// <returns>A new <see cref="Branch"/>.</returns>
138+ public virtual Branch Add ( string name , Commit commit , bool allowOverwrite )
139+ {
140+ Ensure . ArgumentNotNull ( commit , "commit" ) ;
141+
142+ return Add ( name , commit . Sha , allowOverwrite ) ;
143+ }
144+
120145 /// <summary>
121146 /// Create a new local branch with the specified name
122147 /// </summary>
@@ -135,6 +160,35 @@ public virtual Branch Add(string name, string committish, bool allowOverwrite)
135160 return branch ;
136161 }
137162
163+ /// <summary>
164+ /// Deletes the branch with the specified name.
165+ /// </summary>
166+ /// <param name="name">The name of the branch to delete.</param>
167+ public virtual void Remove ( string name )
168+ {
169+ Remove ( name , false ) ;
170+ }
171+
172+ /// <summary>
173+ /// Deletes the branch with the specified name.
174+ /// </summary>
175+ /// <param name="name">The name of the branch to delete.</param>
176+ /// <param name="isRemote">True if the provided <paramref name="name"/> is the name of a remote branch, false otherwise.</param>
177+ public virtual void Remove ( string name , bool isRemote )
178+ {
179+ Ensure . ArgumentNotNullOrEmptyString ( name , "name" ) ;
180+
181+ string branchName = isRemote ? Reference . RemoteTrackingBranchPrefix + name : name ;
182+
183+ Branch branch = this [ branchName ] ;
184+
185+ if ( branch == null )
186+ {
187+ return ;
188+ }
189+
190+ Remove ( branch ) ;
191+ }
138192 /// <summary>
139193 /// Deletes the specified branch.
140194 /// </summary>
@@ -149,6 +203,39 @@ public virtual void Remove(Branch branch)
149203 }
150204 }
151205
206+ /// <summary>
207+ /// Rename an existing local branch, using the default reflog message
208+ /// </summary>
209+ /// <param name="currentName">The current branch name.</param>
210+ /// <param name="newName">The new name the existing branch should bear.</param>
211+ /// <returns>A new <see cref="Branch"/>.</returns>
212+ public virtual Branch Rename ( string currentName , string newName )
213+ {
214+ return Rename ( currentName , newName , false ) ;
215+ }
216+
217+ /// <summary>
218+ /// Rename an existing local branch, using the default reflog message
219+ /// </summary>
220+ /// <param name="currentName">The current branch name.</param>
221+ /// <param name="newName">The new name the existing branch should bear.</param>
222+ /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
223+ /// <returns>A new <see cref="Branch"/>.</returns>
224+ public virtual Branch Rename ( string currentName , string newName , bool allowOverwrite )
225+ {
226+ Ensure . ArgumentNotNullOrEmptyString ( currentName , "currentName" ) ;
227+ Ensure . ArgumentNotNullOrEmptyString ( newName , "newName" ) ;
228+
229+ Branch branch = this [ currentName ] ;
230+
231+ if ( branch == null )
232+ {
233+ throw new LibGit2SharpException ( "No branch named '{0}' exists in the repository." ) ;
234+ }
235+
236+ return Rename ( branch , newName , allowOverwrite ) ;
237+ }
238+
152239 /// <summary>
153240 /// Rename an existing local branch
154241 /// </summary>
0 commit comments