From 816366e23dfe366b938b427eac8ea1c8345ea339 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 26 May 2007 00:26:20 -0700 Subject: Add tests for the last two fixes. This updates t4014 to check the two fixes for git-am and git-commit we observed with "echo" that does backslash interpolation by default without being asked with -e option. Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 4795872a77..df969bb69c 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -16,16 +16,16 @@ test_expect_success setup ' for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file && git update-index file && - git commit -m "Side change #1" && + git commit -m "Side changes #1" && for i in D E F; do echo "$i"; done >>file && git update-index file && - git commit -m "Side change #2" && + git commit -m "Side changes #2" && git tag C2 && 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 "Side change #3" && + git commit -m "Side changes #3 with \\n backslash-n in it." && git checkout master && git diff-tree -p C2 | git apply --index && @@ -66,4 +66,23 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" ' test $cnt = 2 ' +test_expect_success 'commit did not screw up the log message' ' + + git cat-file commit side | grep "^Side .* with .* backslash-n" + +' + +test_expect_success 'format-patch did not screw up the log message' ' + + grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 && + grep "^Subject: .*Side changes #3 with .* backslash-n" patch1 + +' + +test_expect_success 'replay did not screw up the log message' ' + + git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n" + +' + test_done -- cgit v1.2.3 From cd894ee9adf0c026b74761d7b1c0d8dabe4ff4e1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 18 Sep 2007 15:19:47 -0700 Subject: t/t4014: test "am -3" with mode-only change. Earlier commit ece7b74903007cee8d280573647243d46a6f3a95 added a test for rebase that uses "am -3", but this adds a test to check "am -3" itself. Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index df969bb69c..0a6fe53375 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -10,12 +10,15 @@ test_description='Format-patch skipping already incorporated patches' test_expect_success setup ' for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file && - git add file && + cat file >elif && + git add file elif && git commit -m Initial && git checkout -b side && for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file && - git update-index file && + chmod +x elif && + git update-index file elif && + git update-index --chmod=+x elif && git commit -m "Side changes #1" && for i in D E F; do echo "$i"; done >>file && -- cgit v1.2.3 From 7d812145ba7f8df825de618b277186c512d04cfa Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 18 Feb 2008 22:56:02 -0500 Subject: Add more tests for format-patch Tests -o, and an excessively long subject, and --thread, with and without --in-reply-to= Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 0a6fe53375..6e8b5f4516 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -88,4 +88,49 @@ test_expect_success 'replay did not screw up the log message' ' ' +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="" --thread -o patches/ master && + FIRST_MID="" && + 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 -- cgit v1.2.3 From a5a27c79b7e77e28462b6d089e827391b67d3e5f Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 18 Feb 2008 22:56:13 -0500 Subject: Add a --cover-letter option to format-patch If --cover-letter is provided, generate a cover letter message before the patches, numbered 0. Original patch thanks to Johannes Schindelin Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 6e8b5f4516..ac78752067 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -122,6 +122,32 @@ test_expect_success 'thread in-reply-to' ' 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="" --thread -o patches/ master && + FIRST_MID="" && + 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/ && -- cgit v1.2.3 From a8d8173e6c7ff85627377389e40844ec71206f5e Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 19 Feb 2008 02:40:28 -0500 Subject: Add tests for extra headers in format-patch Presently, it works with each header ending with a newline, but not without the newlines. Also add a test to see that multiple "To:" headers get combined. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index ac78752067..28ab7b9a53 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -88,6 +88,40 @@ test_expect_success 'replay did not screw up the log message' ' ' +test_expect_success 'extra headers' ' + + git config format.headers "To: R. E. Cipient +" && + git config --add format.headers "Cc: S. E. Cipient +" && + git format-patch --stdout master..side > patch2 && + sed -e "/^$/Q" patch2 > hdrs2 && + grep "^To: R. E. Cipient $" hdrs2 && + grep "^Cc: S. E. Cipient $" hdrs2 + +' + +test_expect_failure 'extra headers without newlines' ' + + git config --replace-all format.headers "To: R. E. Cipient " && + git config --add format.headers "Cc: S. E. Cipient " && + git format-patch --stdout master..side >patch3 && + sed -e "/^$/Q" patch3 > hdrs3 && + grep "^To: R. E. Cipient $" hdrs3 && + grep "^Cc: S. E. Cipient $" hdrs3 + +' + +test_expect_failure 'extra headers with multiple To:s' ' + + git config --replace-all format.headers "To: R. E. Cipient " && + git config --add format.headers "To: S. E. Cipient " && + git format-patch --stdout master..side > patch4 && + sed -e "/^$/Q" patch4 > hdrs4 && + grep "^To: R. E. Cipient ,$" hdrs4 && + grep "^ *S. E. Cipient $" hdrs4 +' + test_expect_success 'multiple files' ' rm -rf patches/ && -- cgit v1.2.3 From 7d22708b254d4ec28cd865dc5489d175ee6d65c2 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 19 Feb 2008 02:40:31 -0500 Subject: Fix format.headers not ending with a newline Now each value of format.headers will always be treated as a single valid header, and newlines will be inserted between them as needed. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 28ab7b9a53..755fe6dfa6 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -101,7 +101,7 @@ test_expect_success 'extra headers' ' ' -test_expect_failure 'extra headers without newlines' ' +test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R. E. Cipient " && git config --add format.headers "Cc: S. E. Cipient " && -- cgit v1.2.3 From 3ee79d9f59684778151804c02cc6ad155b30efde Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 19 Feb 2008 02:40:33 -0500 Subject: Combine To: and Cc: headers RFC 2822 only permits a single To: header and a single Cc: header, so we need to turn multiple values of each of these into a list. This will be particularly significant with a command-line option to add Cc: headers, where the user can't make sure to configure valid header sets in any easy way. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 755fe6dfa6..43d8841d7d 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -112,7 +112,7 @@ test_expect_success 'extra headers without newlines' ' ' -test_expect_failure 'extra headers with multiple To:s' ' +test_expect_success 'extra headers with multiple To:s' ' git config --replace-all format.headers "To: R. E. Cipient " && git config --add format.headers "To: S. E. Cipient " && -- cgit v1.2.3 From 736cc67dd7f4f8004215e24f876178e6f34c191d Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 19 Feb 2008 02:40:35 -0500 Subject: Support a --cc= option in format-patch When you have particular reviewers you want to sent particular series to, it's nice to be able to generate the whole series with them as additional recipients, without configuring them into your general headers or adding them by hand afterwards. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 43d8841d7d..a39e786f71 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -122,6 +122,14 @@ test_expect_success 'extra headers with multiple To:s' ' grep "^ *S. E. Cipient $" hdrs4 ' +test_expect_success 'additional command line cc' ' + + git config --replace-all format.headers "Cc: R. E. Cipient " && + git format-patch --cc="S. E. Cipient " --stdout master..side | sed -e "/^$/Q" >patch5 && + grep "^Cc: R. E. Cipient ,$" patch5 && + grep "^ *S. E. Cipient $" patch5 +' + test_expect_success 'multiple files' ' rm -rf patches/ && -- cgit v1.2.3 From 1ba0836307c463ce6de11868c85aa46c7396dae4 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sat, 23 Feb 2008 09:41:56 +0100 Subject: t4014: Replace sed's non-standard 'Q' by standard 'q' t4014 test used GNU extension 'Q' in its sed scripts, but the uses can safely be replaced with 'q'. Among other platforms, sed on Mac OS X 10.4 does not accept the former. Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index a39e786f71..16aa99dc0d 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -95,7 +95,7 @@ test_expect_success 'extra headers' ' git config --add format.headers "Cc: S. E. Cipient " && git format-patch --stdout master..side > patch2 && - sed -e "/^$/Q" patch2 > hdrs2 && + sed -e "/^$/q" patch2 > hdrs2 && grep "^To: R. E. Cipient $" hdrs2 && grep "^Cc: S. E. Cipient $" hdrs2 @@ -106,7 +106,7 @@ test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R. E. Cipient " && git config --add format.headers "Cc: S. E. Cipient " && git format-patch --stdout master..side >patch3 && - sed -e "/^$/Q" patch3 > hdrs3 && + sed -e "/^$/q" patch3 > hdrs3 && grep "^To: R. E. Cipient $" hdrs3 && grep "^Cc: S. E. Cipient $" hdrs3 @@ -117,7 +117,7 @@ test_expect_success 'extra headers with multiple To:s' ' git config --replace-all format.headers "To: R. E. Cipient " && git config --add format.headers "To: S. E. Cipient " && git format-patch --stdout master..side > patch4 && - sed -e "/^$/Q" patch4 > hdrs4 && + sed -e "/^$/q" patch4 > hdrs4 && grep "^To: R. E. Cipient ,$" hdrs4 && grep "^ *S. E. Cipient $" hdrs4 ' @@ -125,7 +125,7 @@ test_expect_success 'extra headers with multiple To:s' ' test_expect_success 'additional command line cc' ' git config --replace-all format.headers "Cc: R. E. Cipient " && - git format-patch --cc="S. E. Cipient " --stdout master..side | sed -e "/^$/Q" >patch5 && + git format-patch --cc="S. E. Cipient " --stdout master..side | sed -e "/^$/q" >patch5 && grep "^Cc: R. E. Cipient ,$" patch5 && grep "^ *S. E. Cipient $" patch5 ' -- cgit v1.2.3 From 5d02294c776c46f0d454470c66c16fe9f08fad3d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 2 Mar 2008 15:53:04 +0000 Subject: format-patch: use the diff options for the cover letter, too Earlier, when you called "git format-patch --cover-letter -M", the diffstat in the cover letter would not inherit the "-M". Now it does. While at it, add a few "|| break" statements in the test's loops; otherwise, breakages inside the loops would not be caught. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 16aa99dc0d..6d86b7dd72 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -147,7 +147,7 @@ test_expect_success 'thread' ' for i in patches/0002-* patches/0003-* do grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i + grep "In-Reply-To: $FIRST_MID" $i || break done ' @@ -160,7 +160,7 @@ test_expect_success 'thread in-reply-to' ' for i in patches/* do grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i + grep "In-Reply-To: $FIRST_MID" $i || break done ' @@ -173,7 +173,7 @@ test_expect_success 'thread cover-letter' ' for i in patches/0001-* patches/0002-* patches/0003-* do grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i + grep "In-Reply-To: $FIRST_MID" $i || break done ' @@ -186,7 +186,7 @@ test_expect_success 'thread cover-letter in-reply-to' ' for i in patches/* do grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i + grep "In-Reply-To: $FIRST_MID" $i || break done ' @@ -201,4 +201,14 @@ test_expect_success 'excessive subject' ' ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch ' +test_expect_success 'cover-letter inherits diff options' ' + + git mv file foo && + git commit -m foo && + git format-patch --cover-letter -1 && + ! grep "file => foo .* 0 *$" 0000-cover-letter.patch && + git format-patch --cover-letter -1 -M && + grep "file => foo .* 0 *$" 0000-cover-letter.patch + +' test_done -- cgit v1.2.3 From 859c4fbef589841585f8f21cc567b7016681df7a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 2 Mar 2008 15:53:39 +0000 Subject: format-patch: wrap cover-letter's shortlog sensibly Earlier, overly-long onelines would not be wrapped at all, and indented with 6 spaces. Instead, we now wrap around at 72 characters, with a first-line indent of 2 spaces, and the rest with 4 spaces. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 6d86b7dd72..b2b7a8db85 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -211,4 +211,23 @@ test_expect_success 'cover-letter inherits diff options' ' grep "file => foo .* 0 *$" 0000-cover-letter.patch ' + +cat > expect << EOF + 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. + foo + +EOF + +test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' + + git format-patch --cover-letter -2 && + sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output && + git diff expect output + +' + test_done -- cgit v1.2.3 From 3af828634fa5bdbca1b2061a81df8b3fa73b0d34 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 May 2008 22:28:56 -0700 Subject: tests: do not use implicit "git diff --no-index" As a general principle, we should not use "git diff" to validate the results of what git command that is being tested has done. We would not know if we are testing the command in question, or locating a bug in the cute hack of "git diff --no-index". Rather use test_cmp for that purpose. Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index b2b7a8db85..3583e68e92 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -226,7 +226,7 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' git format-patch --cover-letter -2 && sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output && - git diff expect output + test_cmp expect output ' -- cgit v1.2.3 From 3b2eb186bb738a374d9325b18710b19ec270e55f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 14 Jun 2008 03:25:56 -0400 Subject: fix whitespace violations in test scripts These violations are simply wrong, but were never caught because whitespace policy checking is turned off in the test scripts. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 3583e68e92..7fe853c20d 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -98,7 +98,7 @@ test_expect_success 'extra headers' ' sed -e "/^$/q" patch2 > hdrs2 && grep "^To: R. E. Cipient $" hdrs2 && grep "^Cc: S. E. Cipient $" hdrs2 - + ' test_expect_success 'extra headers without newlines' ' @@ -109,7 +109,7 @@ test_expect_success 'extra headers without newlines' ' sed -e "/^$/q" patch3 > hdrs3 && grep "^To: R. E. Cipient $" hdrs3 && grep "^Cc: S. E. Cipient $" hdrs3 - + ' test_expect_success 'extra headers with multiple To:s' ' @@ -170,7 +170,7 @@ test_expect_success 'thread cover-letter' ' 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-* + for i in patches/0001-* patches/0002-* patches/0003-* do grep "References: $FIRST_MID" $i && grep "In-Reply-To: $FIRST_MID" $i || break -- cgit v1.2.3 From 68daa64df2363f848d818dda9fc414511d9330da Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 24 Aug 2008 22:10:29 -0400 Subject: format-patch: use default diff format even with patch options Previously, running "git format-patch -U5" would cause the low-level diff machinery to change the diff output format from "not specified" to "patch". This meant that format-patch thought we explicitly specified a diff output format, and would not use the default format. The resulting message lacked both the diffstat and the summary, as well as the separating "---". Now format-patch explicitly checks for this condition and uses the default. That means that "git format-patch -p" will now have the "-p" ignored. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 7fe853c20d..9d99dc2887 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -230,4 +230,29 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' ' +cat > expect << EOF +--- + file | 16 ++++++++++++++++ + 1 files changed, 16 insertions(+), 0 deletions(-) + +diff --git a/file b/file +index 40f36c6..2dc5c23 100644 +--- a/file ++++ b/file +@@ -13,4 +13,20 @@ C + 10 + D + E + F ++5 +EOF + +test_expect_success 'format-patch respects -U' ' + + git format-patch -U4 -2 && + sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + test_cmp expect output + +' + test_done -- cgit v1.2.3 From 9800a754f931d05c2d26da9c1b188ae2c2b80eb4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 12 Jan 2009 15:18:02 -0800 Subject: Teach format-patch to handle output directory relative to cwd Without any explicit -o parameter, we correctly avoided putting the resulting patch output to the toplevel. We should do the same when the user gave a relative pathname to be consistent with this case. Noticed by Cesar Eduardo Barros. Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 7fe853c20d..16de4364d7 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -3,7 +3,7 @@ # Copyright (c) 2006 Junio C Hamano # -test_description='Format-patch skipping already incorporated patches' +test_description='various format-patch tests' . ./test-lib.sh @@ -230,4 +230,54 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' ' +test_expect_success 'format-patch from a subdirectory (1)' ' + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 + ) && + case "$filename" in + 0*) + ;; # ok + *) + echo "Oops? $filename" + false + ;; + esac && + test -f "$filename" +' + +test_expect_success 'format-patch from a subdirectory (2)' ' + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 -o .. + ) && + case "$filename" in + ../0*) + ;; # ok + *) + echo "Oops? $filename" + false + ;; + esac && + basename=$(expr "$filename" : ".*/\(.*\)") && + test -f "sub/$basename" +' + +test_expect_success 'format-patch from a subdirectory (3)' ' + here="$TEST_DIRECTORY/$test" && + rm -f 0* && + filename=$( + rm -rf sub && + mkdir -p sub/dir && + cd sub/dir && + git format-patch -1 -o "$here" + ) && + basename=$(expr "$filename" : ".*/\(.*\)") && + test -f "$basename" +' + test_done -- cgit v1.2.3 From 484cf6c3f1169786c45ccda54c9961ef66465c03 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 19 Feb 2009 22:26:30 +0100 Subject: format-patch: threading test reactivation t4014 tests format-patch --thread since 7d812145, but the tests were ineffective right from the start at least for bash and dash. The loops of the form for ...; do something || break; done introduced by 7d812145 and 5d02294 always exit with status 0, even if 'something' failed, because 'break' returns 0 unless there was no loop to break. We take a rather different approach that uses an admittedly heinous inline Perl script to mangle all interesting information into a format that is invariant between runs. We can then test the full patch sequence in one go (with --stdout), doing away with the loop problem. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 142 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 103 insertions(+), 39 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index f045898fe3..345e6deab6 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -138,56 +138,120 @@ test_expect_success 'multiple files' ' 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' ' +check_threading () { + expect="$1" && + shift && + (git format-patch --stdout "$@"; echo $? > status.out) | + # Prints everything between the Message-ID and In-Reply-To, + # and replaces all Message-ID-lookalikes by a sequence number + perl -ne ' + if (/^(message-id|references|in-reply-to)/i) { + $printing = 1; + } elsif (/^\S/) { + $printing = 0; + } + if ($printing) { + $h{$1}=$i++ if (/<([^>]+)>/ and !exists $h{$1}); + for $k (keys %h) {s/$k/$h{$k}/}; + print; + } + print "---\n" if /^From /i; + ' > actual && + test 0 = "$(cat status.out)" && + test_cmp "$expect" actual +} + +cat >> expect.no-threading <]*>\).*$/\1/") && - for i in patches/0002-* patches/0003-* - do - grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i || break - done + check_threading expect.no-threading master ' -test_expect_success 'thread in-reply-to' ' +cat > expect.thread < +--- +Message-Id: <1> +In-Reply-To: <0> +References: <0> +--- +Message-Id: <2> +In-Reply-To: <0> +References: <0> +EOF - rm -rf patches/ && - git checkout side && - git format-patch --in-reply-to="" --thread -o patches/ master && - FIRST_MID="" && - for i in patches/* - do - grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i || break - done +test_expect_success 'thread' ' + check_threading expect.thread --thread master ' -test_expect_success 'thread cover-letter' ' +cat > expect.in-reply-to < +In-Reply-To: <1> +References: <1> +--- +Message-Id: <2> +In-Reply-To: <1> +References: <1> +--- +Message-Id: <3> +In-Reply-To: <1> +References: <1> +EOF - 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 || break - done +test_expect_success 'thread in-reply-to' ' + check_threading expect.in-reply-to --in-reply-to="" \ + --thread master ' -test_expect_success 'thread cover-letter in-reply-to' ' +cat > expect.cover-letter < +--- +Message-Id: <1> +In-Reply-To: <0> +References: <0> +--- +Message-Id: <2> +In-Reply-To: <0> +References: <0> +--- +Message-Id: <3> +In-Reply-To: <0> +References: <0> +EOF - rm -rf patches/ && - git checkout side && - git format-patch --cover-letter --in-reply-to="" --thread -o patches/ master && - FIRST_MID="" && - for i in patches/* - do - grep "References: $FIRST_MID" $i && - grep "In-Reply-To: $FIRST_MID" $i || break - done +test_expect_success 'thread cover-letter' ' + check_threading expect.cover-letter --cover-letter --thread master +' + +cat > expect.cl-irt < +In-Reply-To: <1> +References: <1> +--- +Message-Id: <2> +In-Reply-To: <1> +References: <1> +--- +Message-Id: <3> +In-Reply-To: <1> +References: <1> +--- +Message-Id: <4> +In-Reply-To: <1> +References: <1> +EOF + +test_expect_success 'thread cover-letter in-reply-to' ' + check_threading expect.cl-irt --cover-letter \ + --in-reply-to="" --thread master ' test_expect_success 'excessive subject' ' -- cgit v1.2.3 From 2175c10d5ad2769936f5bf5bcca5ea32715a7307 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 19 Feb 2009 22:26:32 +0100 Subject: format-patch: thread as reply to cover letter even with in-reply-to Currently, format-patch --thread --cover-letter --in-reply-to $parent makes all mails, including the cover letter, a reply to $parent. However, we would want the reader to consider the cover letter above all the patches. This changes the semantics so that only the cover letter is a reply to $parent, while all the patches are formatted as replies to the cover letter. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 345e6deab6..8b970c39a2 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -237,16 +237,19 @@ In-Reply-To: <1> References: <1> --- Message-Id: <2> -In-Reply-To: <1> +In-Reply-To: <0> References: <1> + <0> --- Message-Id: <3> -In-Reply-To: <1> +In-Reply-To: <0> References: <1> + <0> --- Message-Id: <4> -In-Reply-To: <1> +In-Reply-To: <0> References: <1> + <0> EOF test_expect_success 'thread cover-letter in-reply-to' ' -- cgit v1.2.3 From 30984ed2e92651962c6b8bdacf1f84da75d1da95 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 19 Feb 2009 22:26:33 +0100 Subject: format-patch: support deep threading For deep threading mode, i.e., the mode that gives a thread structured like + [PATCH 0/n] Cover letter `-+ [PATCH 1/n] First patch `-+ [PATCH 2/n] Second patch `-+ ... we currently have to use 'git send-email --thread' (the default). On the other hand, format-patch also has a --thread option which gives shallow mode, i.e., + [PATCH 0/n] Cover letter |-+ [PATCH 1/n] First patch |-+ [PATCH 2/n] Second patch ... To reduce the confusion resulting from having two indentically named features in different tools giving different results, let format-patch take an optional argument '--thread=deep' that gives the same output as 'send-mail --thread'. With no argument, or 'shallow', behave as before. Also add a configuration variable format.thread with the same semantics. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 8b970c39a2..ebfc4a6590 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -257,6 +257,126 @@ test_expect_success 'thread cover-letter in-reply-to' ' --in-reply-to="" --thread master ' +test_expect_success 'thread explicit shallow' ' + check_threading expect.cl-irt --cover-letter \ + --in-reply-to="" --thread=shallow master +' + +cat > expect.deep < +--- +Message-Id: <1> +In-Reply-To: <0> +References: <0> +--- +Message-Id: <2> +In-Reply-To: <1> +References: <0> + <1> +EOF + +test_expect_success 'thread deep' ' + check_threading expect.deep --thread=deep master +' + +cat > expect.deep-irt < +In-Reply-To: <1> +References: <1> +--- +Message-Id: <2> +In-Reply-To: <0> +References: <1> + <0> +--- +Message-Id: <3> +In-Reply-To: <2> +References: <1> + <0> + <2> +EOF + +test_expect_success 'thread deep in-reply-to' ' + check_threading expect.deep-irt --thread=deep \ + --in-reply-to="" master +' + +cat > expect.deep-cl < +--- +Message-Id: <1> +In-Reply-To: <0> +References: <0> +--- +Message-Id: <2> +In-Reply-To: <1> +References: <0> + <1> +--- +Message-Id: <3> +In-Reply-To: <2> +References: <0> + <1> + <2> +EOF + +test_expect_success 'thread deep cover-letter' ' + check_threading expect.deep-cl --cover-letter --thread=deep master +' + +cat > expect.deep-cl-irt < +In-Reply-To: <1> +References: <1> +--- +Message-Id: <2> +In-Reply-To: <0> +References: <1> + <0> +--- +Message-Id: <3> +In-Reply-To: <2> +References: <1> + <0> + <2> +--- +Message-Id: <4> +In-Reply-To: <3> +References: <1> + <0> + <2> + <3> +EOF + +test_expect_success 'thread deep cover-letter in-reply-to' ' + check_threading expect.deep-cl-irt --cover-letter \ + --in-reply-to="" --thread=deep master +' + +test_expect_success 'thread via config' ' + git config format.thread true && + check_threading expect.thread master +' + +test_expect_success 'thread deep via config' ' + git config format.thread deep && + check_threading expect.deep master +' + +test_expect_success 'thread config + override' ' + git config format.thread deep && + check_threading expect.thread --thread master +' + +test_expect_success 'thread config + --no-thread' ' + git config format.thread deep && + check_threading expect.no-threading --no-thread master +' + test_expect_success 'excessive subject' ' rm -rf patches/ && -- cgit v1.2.3 From 1f553918a8482ea792e8cd4d5d2c75fe60f68aae Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 28 Feb 2009 21:12:57 +0100 Subject: test-lib: Introduce test_chmod and use it instead of update-index --chmod This function replaces sequences of 'chmod +x' and 'git update-index --chmod=+x' in the test suite, whose purpose is to help filesystems that need core.filemode=false. Two places where only 'chmod +x' was used we also use this new function. The function calls 'git update-index --chmod' without checking core.filemode (unlike some of the call sites did). We do this because the call sites *expect* that the executable bit ends up in the index (ie. it is not the purpose of the call sites to *test* whether git treats 'chmod +x' and 'update-index --chmod=+x' correctly). Therefore, on filesystems with core.filemode=true the 'git update-index --chmod' is a no-op. The function uses --add with update-index to help one call site in t6031-merge-recursive. It makes no difference for the other callers. Signed-off-by: Johannes Sixt --- t/t4014-format-patch.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index ebfc4a6590..f187d15e32 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -16,9 +16,7 @@ test_expect_success setup ' git checkout -b side && for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file && - chmod +x elif && - git update-index file elif && - git update-index --chmod=+x elif && + test_chmod +x elif && git commit -m "Side changes #1" && for i in D E F; do echo "$i"; done >>file && -- cgit v1.2.3 From d7d9c2d04962b5aec34ec891d82dd74262306c56 Mon Sep 17 00:00:00 2001 From: Michael Hendricks Date: Thu, 26 Mar 2009 10:51:05 -0600 Subject: format-patch: add arbitrary email headers format-patch supports the format.headers configuration for adding arbitrary email headers to the patches it outputs. This patch adds support for an --add-header argument which makes the same feature available from the command line. This is useful when the content of custom email headers must change from branch to branch. This patch has been sponsored by Grant Street Group Signed-off-by: Michael Hendricks Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index f187d15e32..11061ddd5b 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' ' grep "^ *S. E. Cipient $" patch5 ' +test_expect_success 'command line headers' ' + + git config --unset-all format.headers && + git format-patch --add-header="Cc: R. E. Cipient " --stdout master..side | sed -e "/^$/q" >patch6 && + grep "^Cc: R. E. Cipient $" patch6 +' + +test_expect_success 'configuration headers and command line headers' ' + + git config --replace-all format.headers "Cc: R. E. Cipient " && + git format-patch --add-header="Cc: S. E. Cipient " --stdout master..side | sed -e "/^$/q" >patch7 && + grep "^Cc: R. E. Cipient ,$" patch7 && + grep "^ *S. E. Cipient $" patch7 +' + test_expect_success 'multiple files' ' rm -rf patches/ && -- cgit v1.2.3 From f044fe2de6f7bbace158853c075a4065f3722265 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Sat, 16 May 2009 02:24:45 -0700 Subject: tests: Add tests for missing format-patch long options Exercise format-patch's --signoff, --in-reply-to and --start-number long options. Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t4014-format-patch.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 't/t4014-format-patch.sh') diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 11061ddd5b..922a8941ed 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -505,4 +505,15 @@ test_expect_success 'format-patch from a subdirectory (3)' ' test -f "$basename" ' +test_expect_success 'format-patch --in-reply-to' ' + git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 && + grep "^In-Reply-To: " patch8 && + grep "^References: " patch8 +' + +test_expect_success 'format-patch --signoff' ' + git format-patch -1 --signoff --stdout | + grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" +' + test_done -- cgit v1.2.3