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 @@ -86,6 +86,7 @@ sub usage {
8686 --[no-]validate * Perform patch sanity checks. Default on.
8787 --[no-]format-patch * understand any non optional arguments as
8888 `git format-patch` ones.
89+ --force * Send even if safety checks would prevent it.
8990
9091EOT
9192 exit (1);
@@ -163,6 +164,7 @@ sub format_2822_time {
163164my ($quiet , $dry_run ) = (0, 0);
164165my $format_patch ;
165166my $compose_filename ;
167+ my $force = 0;
166168
167169# Handle interactive edition of files.
168170my $multiedit ;
@@ -302,6 +304,7 @@ sub signal_handler {
302304 " validate!" => \$validate ,
303305 " format-patch!" => \$format_patch ,
304306 " 8bit-encoding=s" => \$auto_8bit_encoding ,
307+ " force" => \$force ,
305308 );
306309
307310unless ($rc ) {
703706 default => " UTF-8" );
704707}
705708
709+ if (!$force ) {
710+ for my $f (@files ) {
711+ if (get_patch_subject($f ) =~ / \*\*\* SUBJECT HERE \*\*\* / ) {
712+ die " Refusing to send because the patch\n\t $f \n "
713+ . " has the template subject '*** SUBJECT HERE ***'. "
714+ . " Pass --force if you really want to send.\n " ;
715+ }
716+ }
717+ }
718+
706719my $prompting = 0;
707720if (!defined $sender ) {
708721 $sender = $repoauthor || $repocommitter || ' ' ;
Original file line number Diff line number Diff line change @@ -1032,4 +1032,40 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
10321032 test_cmp expected actual
10331033'
10341034
1035+ # Note that the patches in this test are deliberately out of order; we
1036+ # want to make sure it works even if the cover-letter is not in the
1037+ # first mail.
1038+ test_expect_success ' refusing to send cover letter template' '
1039+ clean_fake_sendmail &&
1040+ rm -fr outdir &&
1041+ git format-patch --cover-letter -2 -o outdir &&
1042+ test_must_fail git send-email \
1043+ --from="Example <nobody@example.com>" \
1044+ --to=nobody@example.com \
1045+ --smtp-server="$(pwd)/fake.sendmail" \
1046+ outdir/0002-*.patch \
1047+ outdir/0000-*.patch \
1048+ outdir/0001-*.patch \
1049+ 2>errors >out &&
1050+ grep "SUBJECT HERE" errors &&
1051+ test -z "$(ls msgtxt*)"
1052+ '
1053+
1054+ test_expect_success ' --force sends cover letter template anyway' '
1055+ clean_fake_sendmail &&
1056+ rm -fr outdir &&
1057+ git format-patch --cover-letter -2 -o outdir &&
1058+ git send-email \
1059+ --force \
1060+ --from="Example <nobody@example.com>" \
1061+ --to=nobody@example.com \
1062+ --smtp-server="$(pwd)/fake.sendmail" \
1063+ outdir/0002-*.patch \
1064+ outdir/0000-*.patch \
1065+ outdir/0001-*.patch \
1066+ 2>errors >out &&
1067+ ! grep "SUBJECT HERE" errors &&
1068+ test -n "$(ls msgtxt*)"
1069+ '
1070+
10351071test_done
You can’t perform that action at this time.
0 commit comments