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:
authorBen Straub <bs@github.com>2014-01-22 02:55:40 +0400
committernulltoken <emeric.fermas@gmail.com>2014-03-21 00:16:22 +0400
commit8124810028e03ca1e0cd177868f20e7308e086a3 (patch)
tree0d49550281f7f2e6edababa97b4167dd291be473 /LibGit2Sharp/BranchCollection.cs
parenta09f1939f30efe23bd068297bdd93e2f943efe37 (diff)
Update libgit2 to 36a80fd
https://github.com/libgit2/libgit2/compare/65e9dc6...36a80fd
Diffstat (limited to 'LibGit2Sharp/BranchCollection.cs')
-rw-r--r--LibGit2Sharp/BranchCollection.cs66
1 files changed, 43 insertions, 23 deletions
diff --git a/LibGit2Sharp/BranchCollection.cs b/LibGit2Sharp/BranchCollection.cs
index 3c02ee1d..8075bada 100644
--- a/LibGit2Sharp/BranchCollection.cs
+++ b/LibGit2Sharp/BranchCollection.cs
@@ -111,28 +111,39 @@ namespace LibGit2Sharp
/// </summary>
/// <param name="name">The name of the branch.</param>
/// <param name="commit">The target commit.</param>
+ /// <param name="signature">Identity used for updating the reflog</param>
+ /// <param name="logMessage">Message added to the reflog. If null, the default is "branch: Created from [sha]".</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 Add(string name, Commit commit, bool allowOverwrite = false)
+ public virtual Branch Add(string name, Commit commit, Signature signature, string logMessage = null, bool allowOverwrite = false)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(commit, "commit");
- return Add(name, commit, allowOverwrite, "branch: Created from " + commit.Id);
- }
-
- internal Branch Add(string name, Commit commit, bool allowOverwrite, string logMessage)
- {
- Ensure.ArgumentNotNull(commit, "commit");
+ if (logMessage == null)
+ {
+ logMessage = "branch: Created from " + commit.Id;
+ }
- using (Proxy.git_branch_create(repo.Handle, name, commit.Id, allowOverwrite)) {}
+ using (Proxy.git_branch_create(repo.Handle, name, commit.Id, allowOverwrite, signature.OrDefault(repo.Config), logMessage)) {}
var branch = this[ShortToLocalName(name)];
- LogBranch(branch, logMessage);
return branch;
}
/// <summary>
+ /// Create a new local branch with the specified name, using the default reflog message
+ /// </summary>
+ /// <param name="name">The name of the branch.</param>
+ /// <param name="commit">The target commit.</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 Add(string name, Commit commit, bool allowOverwrite = false)
+ {
+ return Add(name, commit, null, null, allowOverwrite);
+ }
+
+ /// <summary>
/// Deletes the specified branch.
/// </summary>
/// <param name="branch">The branch to delete.</param>
@@ -147,13 +158,15 @@ namespace LibGit2Sharp
}
/// <summary>
- /// Renames an existing local branch with a new name.
+ /// Rename an existing local branch
/// </summary>
/// <param name="branch">The current local branch.</param>
/// <param name="newName">The new name the existing branch should bear.</param>
+ /// <param name="signature">Identity used for updating the reflog</param>
+ /// <param name="logMessage">Message added to the reflog. If null, the default is "branch: renamed [old] to [new]".</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)
+ public virtual Branch Move(Branch branch, string newName, Signature signature, string logMessage = null, bool allowOverwrite = false)
{
Ensure.ArgumentNotNull(branch, "branch");
Ensure.ArgumentNotNullOrEmptyString(newName, "newName");
@@ -165,19 +178,36 @@ namespace LibGit2Sharp
"Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
}
+ if (logMessage == null)
+ {
+ logMessage = string.Format(CultureInfo.InvariantCulture,
+ "branch: renamed {0} to {1}", branch.CanonicalName, Reference.LocalBranchPrefix + newName);
+ }
+
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.Name))
{
- using (ReferenceSafeHandle ref_out = Proxy.git_branch_move(referencePtr, newName, allowOverwrite))
+ using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite, signature.OrDefault(repo.Config), logMessage))
{
}
}
var newBranch = this[newName];
- LogBranch(newBranch, "Branch: renamed " + branch.CanonicalName + " to " + newBranch.CanonicalName);
return newBranch;
}
/// <summary>
+ /// Rename an existing local branch, using the default reflog message
+ /// </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)
+ {
+ return Move(branch, newName, null, null, allowOverwrite);
+ }
+
+ /// <summary>
/// Update properties of a branch.
/// </summary>
/// <param name="branch">The branch to update.</param>
@@ -210,15 +240,5 @@ namespace LibGit2Sharp
"Count = {0}", this.Count());
}
}
-
- private void LogBranch(Branch branch, string logMessage)
- {
- if (string.IsNullOrEmpty(logMessage))
- {
- return;
- }
-
- repo.Refs.Log(branch.CanonicalName).Append(branch.Tip.Id, logMessage, branch.Tip.Committer);
- }
}
}