File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ sub usage {
8585 --[no-]validate * Perform patch sanity checks. Default on.
8686 --[no-]format-patch * understand any non optional arguments as
8787 `git format-patch` ones.
88+ --force * Send even if safety checks would prevent it.
8889
8990EOT
9091 exit (1);
@@ -162,6 +163,7 @@ sub format_2822_time {
162163my ($quiet , $dry_run ) = (0, 0);
163164my $format_patch ;
164165my $compose_filename ;
166+ my $force = 0;
165167
166168# Handle interactive edition of files.
167169my $multiedit ;
@@ -301,6 +303,7 @@ sub signal_handler {
301303 " validate!" => \$validate ,
302304 " format-patch!" => \$format_patch ,
303305 " 8bit-encoding=s" => \$auto_8bit_encoding ,
306+ " force" => \$force ,
304307 );
305308
306309unless ($rc ) {
702705 default => " UTF-8" );
703706}
704707
708+ if (!$force ) {
709+ for my $f (@files ) {
710+ if (get_patch_subject($f ) =~ / \*\*\* SUBJECT HERE \*\*\* / ) {
711+ die " Refusing to send because the patch\n\t $f \n "
712+ . " has the template subject '*** SUBJECT HERE ***'. "
713+ . " Pass --force if you really want to send.\n " ;
714+ }
715+ }
716+ }
717+
705718my $prompting = 0;
706719if (!defined $sender ) {
707720 $sender = $repoauthor || $repocommitter || ' ' ;
Original file line number Diff line number Diff line change @@ -995,4 +995,40 @@ test_expect_success '--8bit-encoding also treats subject' '
995995 test_cmp expected actual
996996'
997997
998+ # Note that the patches in this test are deliberately out of order; we
999+ # want to make sure it works even if the cover-letter is not in the
1000+ # first mail.
1001+ test_expect_success ' refusing to send cover letter template' '
1002+ clean_fake_sendmail &&
1003+ rm -fr outdir &&
1004+ git format-patch --cover-letter -2 -o outdir &&
1005+ test_must_fail git send-email \
1006+ --from="Example <nobody@example.com>" \
1007+ --to=nobody@example.com \
1008+ --smtp-server="$(pwd)/fake.sendmail" \
1009+ outdir/0002-*.patch \
1010+ outdir/0000-*.patch \
1011+ outdir/0001-*.patch \
1012+ 2>errors >out &&
1013+ grep "SUBJECT HERE" errors &&
1014+ test -z "$(ls msgtxt*)"
1015+ '
1016+
1017+ test_expect_success ' --force sends cover letter template anyway' '
1018+ clean_fake_sendmail &&
1019+ rm -fr outdir &&
1020+ git format-patch --cover-letter -2 -o outdir &&
1021+ git send-email \
1022+ --force \
1023+ --from="Example <nobody@example.com>" \
1024+ --to=nobody@example.com \
1025+ --smtp-server="$(pwd)/fake.sendmail" \
1026+ outdir/0002-*.patch \
1027+ outdir/0000-*.patch \
1028+ outdir/0001-*.patch \
1029+ 2>errors >out &&
1030+ ! grep "SUBJECT HERE" errors &&
1031+ test -n "$(ls msgtxt*)"
1032+ '
1033+
9981034test_done
You can’t perform that action at this time.
0 commit comments