3 test_description
='git-send-email'
8 'prepare reference tree' \
9 'echo "1A quick brown fox jumps over the" >file &&
10 echo "lazy dog" >>file &&
12 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
20 echo " echo \"!\$a!\""
21 echo "done >commandline"
24 chmod +x ./fake.sendmail &&
25 git add fake.sendmail &&
26 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
28 test_expect_success
'Extract patches' '
29 patches=`git format-patch -n HEAD^1`
32 test_expect_success
'Send patches' '
33 git send-email --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
41 'Verify commandline' \
42 'diff commandline expected'
44 cat >expected-show-all-headers
<<\EOF
46 (mbox
) Adding cc
: A
<author@example.com
> from line
'From: A <author@example.com>'
48 Server
: relay.example.com
49 MAIL FROM
:<from@example.com
>
50 RCPT TO
:<to@example.com
>,<cc@example.com
>,<author@example.com
>,<bcc@example.com
>
51 From
: Example
<from@example.com
>
53 Cc
: cc@example.com
, A
<author@example.com
>
54 Subject
: [PATCH
1/1] Second.
56 Message-Id
: MESSAGE-ID-STRING
57 X-Mailer
: X-MAILER-STRING
58 In-Reply-To
: <unique-message-id@example.com
>
59 References
: <unique-message-id@example.com
>
64 test_expect_success
'Show all headers' '
67 --from="Example <from@example.com>" \
70 --bcc=bcc@example.com \
71 --in-reply-to="<unique-message-id@example.com>" \
72 --smtp-server relay.example.com \
74 sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
75 -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
76 -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
77 >actual-show-all-headers &&
78 diff -u expected-show-all-headers actual-show-all-headers
82 z64
=$z8$z8$z8$z8$z8$z8$z8$z8
83 z512
=$z64$z64$z64$z64$z64$z64$z64$z64
84 test_expect_success
'reject long lines' '
86 cp $patches longline.patch &&
87 echo $z512$z512 >>longline.patch &&
89 --from="Example <nobody@example.com>" \
90 --to=nobody@example.com \
91 --smtp-server="$(pwd)/fake.sendmail" \
92 $patches longline.patch \
94 grep longline.patch errors
97 test_expect_success
'no patch was sent' '
101 test_expect_success
'allow long lines with --no-validate' '
103 --from="Example <nobody@example.com>" \
104 --to=nobody@example.com \
105 --smtp-server="$(pwd)/fake.sendmail" \
107 $patches longline.patch \
111 test_expect_success
'Invalid In-Reply-To' '
113 --from="Example <nobody@example.com>" \
114 --to=nobody@example.com \
116 --smtp-server="$(pwd)/fake.sendmail" \
119 ! grep "^In-Reply-To: < *>" msgtxt
122 test_expect_success
'Valid In-Reply-To when prompting' '
123 (echo "From Example <from@example.com>"
124 echo "To Example <to@example.com>"
126 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
127 --smtp-server="$(pwd)/fake.sendmail" \
129 ! grep "^In-Reply-To: < *>" msgtxt