diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-06-20 09:16:36 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-06-20 13:28:49 +0400 |
commit | c0bc893032a417e063fd85b55d47f9b805a2e1be (patch) | |
tree | 204fb3c94774a78d1e377cfe5cdc8f633a66fd64 /LibGit2Sharp/ObjectDatabase.cs | |
parent | b62438b78d9676f6ca6d7c73440a80e3eb2bbc72 (diff) |
Upgrade libgit2 binaries to 1d94a7d
Diffstat (limited to 'LibGit2Sharp/ObjectDatabase.cs')
-rw-r--r-- | LibGit2Sharp/ObjectDatabase.cs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 757b73e5..259395fe 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -79,6 +79,15 @@ namespace LibGit2Sharp return treeDefinition.Build(repo); } + internal static string PrettifyMessage(string message) + { + var buffer = new byte[NativeMethods.GIT_PATH_MAX]; + int res = NativeMethods.git_message_prettify(buffer, buffer.Length, message, false); + Ensure.Success(res); + + return Utf8Marshaler.Utf8FromBuffer(buffer) ?? string.Empty; + } + /// <summary> /// Inserts a <see cref = "Commit"/> into the object database, referencing an existing <see cref = "Tree"/>. /// </summary> @@ -101,6 +110,8 @@ namespace LibGit2Sharp Ensure.ArgumentNotNull(tree, "tree"); Ensure.ArgumentNotNull(parents, "parents"); + string prettifiedMessage = PrettifyMessage(message); + IEnumerable<ObjectId> parentIds = parents.Select(p => p.Id); GitOid commitOid; @@ -113,7 +124,7 @@ namespace LibGit2Sharp IntPtr[] parentsPtrs = parentObjectPtrs.Select(o => o.ObjectPtr.DangerousGetHandle()).ToArray(); int res = NativeMethods.git_commit_create(out commitOid, repo.Handle, referenceName, authorHandle, - committerHandle, encoding, message, treePtr.ObjectPtr, parentObjectPtrs.Count(), parentsPtrs); + committerHandle, encoding, prettifiedMessage, treePtr.ObjectPtr, parentObjectPtrs.Count(), parentsPtrs); Ensure.Success(res); } |