diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-27 12:06:41 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-27 12:06:41 -0800 |
commit | 992221d05e42ad9f65a88318ca6339aa1c39fc79 (patch) | |
tree | cf78297e149a396dd87aeefd342a17f4ba6515d0 /t | |
parent | cb99be7c7d2afc71106ffaf400c769c8e72f1bb2 (diff) | |
parent | 2bda2cf4f966ae50d08a32a3839f930c1daac907 (diff) | |
download | git-992221d05e42ad9f65a88318ca6339aa1c39fc79.tar.gz git-992221d05e42ad9f65a88318ca6339aa1c39fc79.tar.xz |
Merge branch 'db/cover-letter'
* db/cover-letter:
Improve collection of information for format-patch --cover-letter
Add API access to shortlog
t4014: Replace sed's non-standard 'Q' by standard 'q'
Support a --cc=<email> option in format-patch
Combine To: and Cc: headers
Fix format.headers not ending with a newline
Add tests for extra headers in format-patch
Add a --cover-letter option to format-patch
Export some email and pretty-printing functions
Improve message-id generation flow control for format-patch
Add more tests for format-patch
Conflicts:
builtin-log.c
builtin-shortlog.c
pretty.c
Diffstat (limited to 't')
-rwxr-xr-x | t/t4013-diff-various.sh | 1 | ||||
-rw-r--r-- | t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ | 100 | ||||
-rwxr-xr-x | t/t4014-format-patch.sh | 113 |
3 files changed, 214 insertions, 0 deletions
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 9eec75422..6b4d1c52b 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -245,6 +245,7 @@ format-patch --inline --stdout initial..master format-patch --inline --stdout --subject-prefix=TESTCASE initial..master config format.subjectprefix DIFFERENT_PREFIX format-patch --inline --stdout initial..master^^ +format-patch --stdout --cover-letter -n initial..master^ diff --abbrev initial..side diff -r initial..side diff --git a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ new file mode 100644 index 000000000..0151453b7 --- /dev/null +++ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ @@ -0,0 +1,100 @@ +$ git format-patch --stdout --cover-letter -n initial..master^ +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: C O Mitter <committer@example.com> +Date: Mon, 26 Jun 2006 00:05:00 +0000 +Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE *** + +*** BLURB HERE *** + +A U Thor (2): + Second + Third + + dir/sub | 4 ++++ + file0 | 3 +++ + file1 | 3 +++ + file2 | 3 --- + 4 files changed, 10 insertions(+), 3 deletions(-) + create mode 100644 file1 + delete mode 100644 file2 + +From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:01:00 +0000 +Subject: [DIFFERENT_PREFIX 1/2] Second + +This is the second commit. +--- + dir/sub | 2 ++ + file0 | 3 +++ + file2 | 3 --- + 3 files changed, 5 insertions(+), 3 deletions(-) + delete mode 100644 file2 + +diff --git a/dir/sub b/dir/sub +index 35d242b..8422d40 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -1,2 +1,4 @@ + A + B ++C ++D +diff --git a/file0 b/file0 +index 01e79c3..b414108 100644 +--- a/file0 ++++ b/file0 +@@ -1,3 +1,6 @@ + 1 + 2 + 3 ++4 ++5 ++6 +diff --git a/file2 b/file2 +deleted file mode 100644 +index 01e79c3..0000000 +--- a/file2 ++++ /dev/null +@@ -1,3 +0,0 @@ +-1 +-2 +-3 +-- +g-i-t--v-e-r-s-i-o-n + + +From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001 +From: A U Thor <author@example.com> +Date: Mon, 26 Jun 2006 00:02:00 +0000 +Subject: [DIFFERENT_PREFIX 2/2] Third + +--- + dir/sub | 2 ++ + file1 | 3 +++ + 2 files changed, 5 insertions(+), 0 deletions(-) + create mode 100644 file1 + +diff --git a/dir/sub b/dir/sub +index 8422d40..cead32e 100644 +--- a/dir/sub ++++ b/dir/sub +@@ -2,3 +2,5 @@ A + B + C + D ++E ++F +diff --git a/file1 b/file1 +new file mode 100644 +index 0000000..b1e6722 +--- /dev/null ++++ b/file1 +@@ -0,0 +1,3 @@ ++A ++B ++C +-- +g-i-t--v-e-r-s-i-o-n + +$ diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 0a6fe5337..16aa99dc0 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -88,4 +88,117 @@ test_expect_success 'replay did not screw up the log message' ' ' +test_expect_success 'extra headers' ' + + git config format.headers "To: R. E. Cipient <rcipient@example.com> +" && + git config --add format.headers "Cc: S. E. Cipient <scipient@example.com> +" && + git format-patch --stdout master..side > patch2 && + sed -e "/^$/q" patch2 > hdrs2 && + grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs2 && + grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs2 + +' + +test_expect_success 'extra headers without newlines' ' + + git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" && + git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>" && + git format-patch --stdout master..side >patch3 && + sed -e "/^$/q" patch3 > hdrs3 && + grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs3 && + grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs3 + +' + +test_expect_success 'extra headers with multiple To:s' ' + + git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" && + git config --add format.headers "To: S. E. Cipient <scipient@example.com>" && + git format-patch --stdout master..side > patch4 && + sed -e "/^$/q" patch4 > hdrs4 && + grep "^To: R. E. Cipient <rcipient@example.com>,$" hdrs4 && + grep "^ *S. E. Cipient <scipient@example.com>$" hdrs4 +' + +test_expect_success 'additional command line cc' ' + + git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" && + git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch5 && + grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch5 && + grep "^ *S. E. Cipient <scipient@example.com>$" patch5 +' + +test_expect_success 'multiple files' ' + + rm -rf patches/ && + git checkout side && + git format-patch -o patches/ master && + ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch +' + +test_expect_success 'thread' ' + + rm -rf patches/ && + git checkout side && + git format-patch --thread -o patches/ master && + FIRST_MID=$(grep "Message-Id:" patches/0001-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") && + for i in patches/0002-* patches/0003-* + do + grep "References: $FIRST_MID" $i && + grep "In-Reply-To: $FIRST_MID" $i + done +' + +test_expect_success 'thread in-reply-to' ' + + rm -rf patches/ && + git checkout side && + git format-patch --in-reply-to="<test.message>" --thread -o patches/ master && + FIRST_MID="<test.message>" && + for i in patches/* + do + grep "References: $FIRST_MID" $i && + grep "In-Reply-To: $FIRST_MID" $i + done +' + +test_expect_success 'thread cover-letter' ' + + rm -rf patches/ && + git checkout side && + git format-patch --cover-letter --thread -o patches/ master && + FIRST_MID=$(grep "Message-Id:" patches/0000-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") && + for i in patches/0001-* patches/0002-* patches/0003-* + do + grep "References: $FIRST_MID" $i && + grep "In-Reply-To: $FIRST_MID" $i + done +' + +test_expect_success 'thread cover-letter in-reply-to' ' + + rm -rf patches/ && + git checkout side && + git format-patch --cover-letter --in-reply-to="<test.message>" --thread -o patches/ master && + FIRST_MID="<test.message>" && + for i in patches/* + do + grep "References: $FIRST_MID" $i && + grep "In-Reply-To: $FIRST_MID" $i + done +' + +test_expect_success 'excessive subject' ' + + rm -rf patches/ && + git checkout side && + for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file && + git update-index file && + git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." && + git format-patch -o patches/ master..side && + ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch +' + test_done |