Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions LibGit2Sharp/Commit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Commit : GitObject
private readonly ILazy<Signature> lazyAuthor;
private readonly ILazy<Signature> lazyCommitter;
private readonly ILazy<string> lazyMessage;
private readonly ILazy<string> lazyMessageRaw;
private readonly ILazy<string> lazyMessageShort;
private readonly ILazy<string> lazyEncoding;

Expand All @@ -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);

Expand All @@ -66,6 +68,11 @@ public virtual TreeEntry this[string relativePath]
/// </summary>
public virtual string Message { get { return lazyMessage.Value; } }

/// <summary>
/// Gets the raw, unmodified commit message.
/// </summary>
public virtual string MessageRaw { get { return lazyMessageRaw.Value; } }

/// <summary>
/// Gets the short commit message which is usually the first line of the commit.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/CommitRewriteInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static CommitRewriteInfo From(Commit commit)
{
Author = commit.Author,
Committer = commit.Committer,
Message = commit.Message
Message = commit.MessageRaw
};
}

Expand Down
4 changes: 4 additions & 0 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions LibGit2Sharp/Core/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down