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:
-rw-r--r--LibGit2Sharp/Core/HistoryRewriter.cs7
-rw-r--r--LibGit2Sharp/Core/Proxy.cs4
-rw-r--r--LibGit2Sharp/ObjectDatabase.cs35
-rw-r--r--LibGit2Sharp/Repository.cs2
4 files changed, 39 insertions, 9 deletions
diff --git a/LibGit2Sharp/Core/HistoryRewriter.cs b/LibGit2Sharp/Core/HistoryRewriter.cs
index 67dd9902..6dfdf961 100644
--- a/LibGit2Sharp/Core/HistoryRewriter.cs
+++ b/LibGit2Sharp/Core/HistoryRewriter.cs
@@ -222,8 +222,11 @@ namespace LibGit2Sharp.Core
return;
}
- var newCommit = repo.ObjectDatabase.CreateCommit(newHeader.Message, newHeader.Author,
- newHeader.Committer, newTree,
+ var newCommit = repo.ObjectDatabase.CreateCommit(newHeader.Author,
+ newHeader.Committer,
+ newHeader.Message,
+ true,
+ newTree,
mappedNewParents);
// Record the rewrite
diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs
index 09afbcc7..e78c56e0 100644
--- a/LibGit2Sharp/Core/Proxy.cs
+++ b/LibGit2Sharp/Core/Proxy.cs
@@ -316,7 +316,7 @@ namespace LibGit2Sharp.Core
string referenceName,
Signature author,
Signature committer,
- string prettifiedMessage,
+ string message,
Tree tree,
GitOid[] parentIds)
{
@@ -331,7 +331,7 @@ namespace LibGit2Sharp.Core
int res = NativeMethods.git_commit_create_from_oids(
out commitOid, repo, referenceName, authorHandle,
- committerHandle, null, prettifiedMessage,
+ committerHandle, null, message,
ref treeOid, parentPtrs.Count, parentPtrs.ToArray());
Ensure.ZeroResult(res);
diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs
index bb43e640..a95520b5 100644
--- a/LibGit2Sharp/ObjectDatabase.cs
+++ b/LibGit2Sharp/ObjectDatabase.cs
@@ -191,12 +191,36 @@ namespace LibGit2Sharp
/// <param name="tree">The <see cref="Tree"/> of the <see cref="Commit"/> to be created.</param>
/// <param name="parents">The parents of the <see cref="Commit"/> to be created.</param>
/// <returns>The created <see cref="Commit"/>.</returns>
+ [Obsolete("This method will be removed in the next release. Please use CreateCommit(Signature, Signature, string, bool, Tree, IEnumerable<Commit>) instead.")]
public virtual Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable<Commit> parents)
{
- return CreateCommit(message, author, committer, tree, parents, null);
+ return CreateCommit(author, committer, message, true, tree, parents, null);
}
- internal Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable<Commit> parents, string referenceName)
+ /// <summary>
+ /// Inserts a <see cref="Commit"/> into the object database, referencing an existing <see cref="Tree"/>.
+ /// <para>
+ /// Prettifing the message includes:
+ /// * Removing empty lines from the beginning and end.
+ /// * Removing trailing spaces from every line.
+ /// * Turning multiple consecutive empty lines between paragraphs into just one empty line.
+ /// * Ensuring the commit message ends with a newline.
+ /// * Removing every line starting with "#".
+ /// </para>
+ /// </summary>
+ /// <param name="author">The <see cref="Signature"/> of who made the change.</param>
+ /// <param name="committer">The <see cref="Signature"/> of who added the change to the repository.</param>
+ /// <param name="message">The description of why a change was made to the repository.</param>
+ /// <param name="prettifyMessage">True to prettify the message, or false to leave it as is</param>
+ /// <param name="tree">The <see cref="Tree"/> of the <see cref="Commit"/> to be created.</param>
+ /// <param name="parents">The parents of the <see cref="Commit"/> to be created.</param>
+ /// <returns>The created <see cref="Commit"/>.</returns>
+ public virtual Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable<Commit> parents)
+ {
+ return CreateCommit(author, committer, message, prettifyMessage, tree, parents, null);
+ }
+
+ internal Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable<Commit> parents, string referenceName)
{
Ensure.ArgumentNotNull(message, "message");
Ensure.ArgumentDoesNotContainZeroByte(message, "message");
@@ -205,10 +229,13 @@ namespace LibGit2Sharp
Ensure.ArgumentNotNull(tree, "tree");
Ensure.ArgumentNotNull(parents, "parents");
- string prettifiedMessage = Proxy.git_message_prettify(message);
+ if (prettifyMessage)
+ {
+ message = Proxy.git_message_prettify(message);
+ }
GitOid[] parentIds = parents.Select(p => p.Id.Oid).ToArray();
- ObjectId commitId = Proxy.git_commit_create(repo.Handle, referenceName, author, committer, prettifiedMessage, tree, parentIds);
+ ObjectId commitId = Proxy.git_commit_create(repo.Handle, referenceName, author, committer, message, tree, parentIds);
return repo.Lookup<Commit>(commitId);
}
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 7854e8c4..40358826 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -880,7 +880,7 @@ namespace LibGit2Sharp
var parents = RetrieveParentsOfTheCommitBeingCreated(amendPreviousCommit);
- Commit result = ObjectDatabase.CreateCommit(message, author, committer, tree, parents, "HEAD");
+ Commit result = ObjectDatabase.CreateCommit(author, committer, message, true, tree, parents, "HEAD");
Proxy.git_repository_state_cleanup(handle);