From 254e0a33ee66c65948e15efbe93a810c4077e324 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 24 Nov 2015 13:43:43 +0100 Subject: diff: include commit message when formatting patch When formatting a patch as email we do not include the commit's message in the formatted patch output. Implement this and add a test that verifies behavior. --- tests/diff/format_email.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/diff') diff --git a/tests/diff/format_email.c b/tests/diff/format_email.c index 18ad99bd5..8a0128898 100644 --- a/tests/diff/format_email.c +++ b/tests/diff/format_email.c @@ -97,6 +97,47 @@ void test_diff_format_email__simple(void) email, "9264b96c6d104d0e07ae33d3007b6a48246c6f92", &opts); } +void test_diff_format_email__with_message(void) +{ + git_diff_format_email_options opts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT; + const char *email = "From 627e7e12d87e07a83fad5b6bfa25e86ead4a5270 Mon Sep 17 00:00:00 2001\n" \ + "From: Patrick Steinhardt \n" \ + "Date: Tue, 24 Nov 2015 13:34:39 +0100\n" \ + "Subject: [PATCH] Modify content with message\n" \ + "\n" \ + "Modify content of file3.txt by appending a new line. Make this\n" \ + "commit message somewhat longer to test behavior with newlines\n" \ + "embedded in the message body.\n" \ + "\n" \ + "Also test if new paragraphs are included correctly.\n" \ + "---\n" \ + " file3.txt | 1 +\n" \ + " 1 file changed, 1 insertion(+), 0 deletions(-)\n" \ + "\n" \ + "diff --git a/file3.txt b/file3.txt\n" \ + "index 9a2d780..7309653 100644\n" \ + "--- a/file3.txt\n" \ + "+++ b/file3.txt\n" \ + "@@ -3,3 +3,4 @@ file3!\n" \ + " file3\n" \ + " file3\n" \ + " file3\n" \ + "+file3\n" \ + "--\n" \ + "libgit2 0.23.0\n" \ + "\n"; + + opts.body = "Modify content of file3.txt by appending a new line. Make this\n" \ + "commit message somewhat longer to test behavior with newlines\n" \ + "embedded in the message body.\n" \ + "\n" \ + "Also test if new paragraphs are included correctly."; + + assert_email_match( + email, "627e7e12d87e07a83fad5b6bfa25e86ead4a5270", &opts); +} + + void test_diff_format_email__multiple(void) { git_oid oid; -- cgit v1.2.3