diff --git a/LibGit2Sharp/Commit.cs b/LibGit2Sharp/Commit.cs index 357567d8a..34633ccbe 100644 --- a/LibGit2Sharp/Commit.cs +++ b/LibGit2Sharp/Commit.cs @@ -21,6 +21,7 @@ public class Commit : GitObject private readonly ILazy lazyAuthor; private readonly ILazy lazyCommitter; private readonly ILazy lazyMessage; + private readonly ILazy lazyMessageRaw; private readonly ILazy lazyMessageShort; private readonly ILazy lazyEncoding; @@ -43,6 +44,7 @@ internal Commit(Repository repo, ObjectId id) lazyCommitter = group1.AddLazy(Proxy.git_commit_committer); group2 = new GitObjectLazyGroup(this.repo, id); lazyMessage = group2.AddLazy(Proxy.git_commit_message); + lazyMessageRaw = group2.AddLazy(Proxy.git_commit_message_raw); lazyMessageShort = group2.AddLazy(Proxy.git_commit_summary); lazyEncoding = group2.AddLazy(RetrieveEncodingOf); @@ -66,6 +68,11 @@ public virtual TreeEntry this[string relativePath] /// public virtual string Message { get { return lazyMessage.Value; } } + /// + /// Gets the raw, unmodified commit message. + /// + public virtual string MessageRaw { get { return lazyMessageRaw.Value; } } + /// /// Gets the short commit message which is usually the first line of the commit. /// diff --git a/LibGit2Sharp/CommitRewriteInfo.cs b/LibGit2Sharp/CommitRewriteInfo.cs index ca7399578..8a50001ac 100644 --- a/LibGit2Sharp/CommitRewriteInfo.cs +++ b/LibGit2Sharp/CommitRewriteInfo.cs @@ -31,7 +31,7 @@ public static CommitRewriteInfo From(Commit commit) { Author = commit.Author, Committer = commit.Committer, - Message = commit.Message + Message = commit.MessageRaw }; } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index cbb850b16..380790137 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -422,6 +422,10 @@ internal static extern unsafe int git_commit_create_with_signature( [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] internal static extern unsafe string git_commit_message(git_object* commit); + [DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] + internal static extern unsafe string git_commit_message_raw(git_object* commit); + [DllImport(libgit2, CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] internal static extern unsafe string git_commit_summary(git_object* commit); diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 83d35e22c..e4900b7be 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -388,6 +388,11 @@ public static unsafe string git_commit_message(ObjectHandle obj) return NativeMethods.git_commit_message(obj); } + public static unsafe string git_commit_message_raw(ObjectHandle obj) + { + return NativeMethods.git_commit_message_raw(obj); + } + public static unsafe string git_commit_summary(ObjectHandle obj) { return NativeMethods.git_commit_summary(obj);