X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;ds=sidebyside;f=t%2Ft4014-format-patch.sh;h=f87434b9f8e0d520813389e6ea7c94f74222767b;hb=7e7db5e4520388d3a6f1efbe2f7a29d43bd06a2b;hp=3bc1cccf8869aef26e175e207dc2923d3ddb1e65;hpb=ad336054068074ed614d0bb54bb169e5263499d7;p=git.git diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 3bc1cccf8..f87434b9f 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -93,9 +93,9 @@ 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 && - grep "^To: R. E. Cipient $" hdrs2 && - grep "^Cc: S. E. Cipient $" hdrs2 + sed -e "/^\$/q" patch2 > hdrs2 && + grep "^To: R. E. Cipient \$" hdrs2 && + grep "^Cc: S. E. Cipient \$" hdrs2 ' @@ -104,9 +104,9 @@ 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 && - grep "^To: R. E. Cipient $" hdrs3 && - grep "^Cc: S. E. Cipient $" hdrs3 + sed -e "/^\$/q" patch3 > hdrs3 && + grep "^To: R. E. Cipient \$" hdrs3 && + grep "^Cc: S. E. Cipient \$" hdrs3 ' @@ -115,32 +115,84 @@ 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 && - grep "^To: R. E. Cipient ,$" hdrs4 && - grep "^ *S. E. Cipient $" hdrs4 + sed -e "/^\$/q" patch4 > hdrs4 && + grep "^To: R. E. Cipient ,\$" hdrs4 && + 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 + 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 '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 + 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 + 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 'command line To: header' ' + + git config --unset-all format.headers && + git format-patch --to="R. E. Cipient " --stdout master..side | sed -e "/^\$/q" >patch8 && + grep "^To: R. E. Cipient \$" patch8 +' + +test_expect_success 'configuration To: header' ' + + git config format.to "R. E. Cipient " && + git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 && + grep "^To: R. E. Cipient \$" patch9 +' + +test_expect_success '--no-to overrides config.to' ' + + git config --replace-all format.to \ + "R. E. Cipient " && + git format-patch --no-to --stdout master..side | + sed -e "/^\$/q" >patch10 && + ! grep "^To: R. E. Cipient \$" patch10 +' + +test_expect_success '--no-to and --to replaces config.to' ' + + git config --replace-all format.to \ + "Someone " && + git format-patch --no-to --to="Someone Else " \ + --stdout master..side | + sed -e "/^\$/q" >patch11 && + ! grep "^To: Someone \$" patch11 && + grep "^To: Someone Else \$" patch11 +' + +test_expect_success '--no-cc overrides config.cc' ' + + git config --replace-all format.cc \ + "C. E. Cipient " && + git format-patch --no-cc --stdout master..side | + sed -e "/^\$/q" >patch12 && + ! grep "^Cc: C. E. Cipient \$" patch12 +' + +test_expect_success '--no-add-headers overrides config.headers' ' + + git config --replace-all format.headers \ + "Header1: B. E. Cipient " && + git format-patch --no-add-headers --stdout master..side | + sed -e "/^\$/q" >patch13 && + ! grep "^Header1: B. E. Cipient \$" patch13 ' test_expect_success 'multiple files' ' @@ -406,9 +458,9 @@ 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 && + ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch && git format-patch --cover-letter -1 -M && - grep "file => foo .* 0 *$" 0000-cover-letter.patch + grep "file => foo .* 0 *\$" 0000-cover-letter.patch ' @@ -425,7 +477,7 @@ 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 && + sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output && test_cmp expect output ' @@ -450,7 +502,7 @@ 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 && + sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && test_cmp expect output ' @@ -471,7 +523,7 @@ EOF test_expect_success 'format-patch -p suppresses stat' ' git format-patch -p -2 && - sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && test_cmp expect output ' @@ -557,4 +609,60 @@ test_expect_success 'format-patch -- ' ' ! grep "Use .--" error ' +test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' + git format-patch --ignore-if-in-upstream HEAD +' + +test_expect_success 'format-patch --signature' ' + git format-patch --stdout --signature="my sig" -1 >output && + grep "my sig" output +' + +test_expect_success 'format-patch with format.signature config' ' + git config format.signature "config sig" && + git format-patch --stdout -1 >output && + grep "config sig" output +' + +test_expect_success 'format-patch --signature overrides format.signature' ' + git config format.signature "config sig" && + git format-patch --stdout --signature="overrides" -1 >output && + ! grep "config sig" output && + grep "overrides" output +' + +test_expect_success 'format-patch --no-signature ignores format.signature' ' + git config format.signature "config sig" && + git format-patch --stdout --signature="my sig" --no-signature \ + -1 >output && + ! grep "config sig" output && + ! grep "my sig" output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --signature --cover-letter' ' + git config --unset-all format.signature && + git format-patch --stdout --signature="my sig" --cover-letter \ + -1 >output && + grep "my sig" output && + test 2 = $(grep "my sig" output | wc -l) +' + +test_expect_success 'format.signature="" supresses signatures' ' + git config format.signature "" && + git format-patch --stdout -1 >output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --no-signature supresses signatures' ' + git config --unset-all format.signature && + git format-patch --stdout --no-signature -1 >output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --signature="" supresses signatures' ' + git format-patch --signature="" -1 >output && + ! grep "^-- \$" output +' + test_done