diff --git a/LibGit2Sharp/Core/HistoryRewriter.cs b/LibGit2Sharp/Core/HistoryRewriter.cs
index 67dd9902f..6dfdf961f 100644
--- a/LibGit2Sharp/Core/HistoryRewriter.cs
+++ b/LibGit2Sharp/Core/HistoryRewriter.cs
@@ -222,8 +222,11 @@ private void RewriteCommit(Commit commit)
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 09afbcc78..e78c56e04 100644
--- a/LibGit2Sharp/Core/Proxy.cs
+++ b/LibGit2Sharp/Core/Proxy.cs
@@ -316,7 +316,7 @@ public static ObjectId git_commit_create(
string referenceName,
Signature author,
Signature committer,
- string prettifiedMessage,
+ string message,
Tree tree,
GitOid[] parentIds)
{
@@ -331,7 +331,7 @@ public static ObjectId git_commit_create(
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 bb43e6401..a95520b59 100644
--- a/LibGit2Sharp/ObjectDatabase.cs
+++ b/LibGit2Sharp/ObjectDatabase.cs
@@ -191,12 +191,36 @@ public virtual Tree CreateTree(TreeDefinition treeDefinition)
/// The of the to be created.
/// The parents of the to be created.
/// The created .
+ [Obsolete("This method will be removed in the next release. Please use CreateCommit(Signature, Signature, string, bool, Tree, IEnumerable) instead.")]
public virtual Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable 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 parents, string referenceName)
+ ///
+ /// Inserts a into the object database, referencing an existing .
+ ///
+ /// 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 "#".
+ ///
+ ///
+ /// The of who made the change.
+ /// The of who added the change to the repository.
+ /// The description of why a change was made to the repository.
+ /// True to prettify the message, or false to leave it as is
+ /// The of the to be created.
+ /// The parents of the to be created.
+ /// The created .
+ public virtual Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable parents)
+ {
+ return CreateCommit(author, committer, message, prettifyMessage, tree, parents, null);
+ }
+
+ internal Commit CreateCommit(Signature author, Signature committer, string message, bool prettifyMessage, Tree tree, IEnumerable parents, string referenceName)
{
Ensure.ArgumentNotNull(message, "message");
Ensure.ArgumentDoesNotContainZeroByte(message, "message");
@@ -205,10 +229,13 @@ internal Commit CreateCommit(string message, Signature author, Signature committ
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(commitId);
}
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 7854e8c4d..403588262 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -880,7 +880,7 @@ public Commit Commit(string message, Signature author, Signature committer, bool
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);