1298
test_cmp expected actual
1299
'
1300
1301
+test_expect_success $PREREQ 'setup expect' '
1302
+cat >email-using-8bit <<EOF
1303
+From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1304
+Message-Id: <bogus-message-id@example.com>
1305
+From: A U Thor <author@example.com>
1306
+Date: Sat, 12 Jun 2010 15:53:58 +0200
1307
+Content-Type: text/plain; charset=UTF-8
1308
+Subject: Nothing to see here.
1309
+
1310
+Dieser Betreff enthält auch einen Umlaut!
1311
+EOF
1312
+'
1313
+
1314
+test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data' '
1315
+ clean_fake_sendmail &&
1316
+ git config sendemail.transferEncoding 7bit &&
1317
+ test_must_fail git send-email \
1318
+ --transfer-encoding=7bit \
1319
+ --smtp-server="$(pwd)/fake.sendmail" \
1320
+ email-using-8bit \
1321
+ 2>errors >out &&
1322
+ grep "cannot send message as 7bit" errors &&
1323
+ test -z "$(ls msgtxt*)"
1324
+'
1325
+
1326
+test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
1327
+ clean_fake_sendmail &&
1328
+ git config sendemail.transferEncoding 8bit
1329
+ test_must_fail git send-email \
1330
+ --transfer-encoding=7bit \
1331
+ --smtp-server="$(pwd)/fake.sendmail" \
1332
+ email-using-8bit \
1333
+ 2>errors >out &&
1334
+ grep "cannot send message as 7bit" errors &&
1335
+ test -z "$(ls msgtxt*)"
1336
+'
1337
+
1338
+test_expect_success $PREREQ 'sendemail.transferencoding=8bit' '
1339
+ clean_fake_sendmail &&
1340
+ git send-email \
1341
+ --transfer-encoding=8bit \
1342
+ --smtp-server="$(pwd)/fake.sendmail" \
1343
+ email-using-8bit \
1344
+ 2>errors >out &&
1345
+ sed '1,/^$/d' msgtxt1 >actual &&
1346
+ sed '1,/^$/d' email-using-8bit >expected &&
1347
+ test_cmp expected actual
1348
+'
1349
+
1350
+test_expect_success $PREREQ 'setup expect' '
1351
+cat >expected <<EOF
1352
+Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1353
+EOF
1354
+'
1355
+
1356
+test_expect_success $PREREQ '8-bit and sendemail.transferencoding=quoted-printable' '
1357
+ clean_fake_sendmail &&
1358
+ git send-email \
1359
+ --transfer-encoding=quoted-printable \
1360
+ --smtp-server="$(pwd)/fake.sendmail" \
1361
+ email-using-8bit \
1362
+ 2>errors >out &&
1363
+ sed '1,/^$/d' msgtxt1 >actual &&
1364
+ test_cmp expected actual
1365
+'
1366
+
1367
+test_expect_success $PREREQ 'setup expect' '
1368
+cat >expected <<EOF
1369
+RGllc2VyIEJldHJlZmYgZW50aMOkbHQgYXVjaCBlaW5lbiBVbWxhdXQhCg==
1370
+EOF
1371
+'
1372
+
1373
+test_expect_success $PREREQ '8-bit and sendemail.transferencoding=base64' '
1374
+ clean_fake_sendmail &&
1375
+ git send-email \
1376
+ --transfer-encoding=base64 \
1377
+ --smtp-server="$(pwd)/fake.sendmail" \
1378
+ email-using-8bit \
1379
+ 2>errors >out &&
1380
+ sed '1,/^$/d' msgtxt1 >actual &&
1381
+ test_cmp expected actual
1382
+'
1383
+
1384
+test_expect_success $PREREQ 'setup expect' '
1385
+cat >email-using-qp <<EOF
1386
+From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1387
+Message-Id: <bogus-message-id@example.com>
1388
+From: A U Thor <author@example.com>
1389
+Date: Sat, 12 Jun 2010 15:53:58 +0200
1390
+MIME-Version: 1.0
1391
+Content-Transfer-Encoding: quoted-printable
1392
+Content-Type: text/plain; charset=UTF-8
1393
+Subject: Nothing to see here.
1394
+
1395
+Dieser Betreff enth=C3=A4lt auch einen Umlaut!
1396
+EOF
1397
+'
1398
+
1399
+test_expect_success $PREREQ 'convert from quoted-printable to base64' '
1400
+ clean_fake_sendmail &&
1401
+ git send-email \
1402
+ --transfer-encoding=base64 \
1403
+ --smtp-server="$(pwd)/fake.sendmail" \
1404
+ email-using-qp \
1405
+ 2>errors >out &&
1406
+ sed '1,/^$/d' msgtxt1 >actual &&
1407
+ test_cmp expected actual
1408
+'
1409
+
1410
+test_expect_success $PREREQ 'setup expect' "
1411
+tr -d '\\015' | tr '%' '\\015' > email-using-crlf <<EOF
1412
+From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1413
+Message-Id: <bogus-message-id@example.com>
1414
+From: A U Thor <author@example.com>
1415
+Date: Sat, 12 Jun 2010 15:53:58 +0200
1416
+Content-Type: text/plain; charset=UTF-8
1417
+Subject: Nothing to see here.
1418
+
1419
+Look, I have a CRLF and an = sign!%
1420
+EOF
1421
+"
1422
+
1423
+test_expect_success $PREREQ 'setup expect' '
1424
+cat >expected <<EOF
1425
+Look, I have a CRLF and an =3D sign!=0D
1426
+EOF
1427
+'
1428
+
1429
+test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=quoted-printable' '
1430
+ clean_fake_sendmail &&
1431
+ git send-email \
1432
+ --transfer-encoding=quoted-printable \
1433
+ --smtp-server="$(pwd)/fake.sendmail" \
1434
+ email-using-crlf \
1435
+ 2>errors >out &&
1436
+ sed '1,/^$/d' msgtxt1 >actual &&
1437
+ test_cmp expected actual
1438
+'
1439
+
1440
+test_expect_success $PREREQ 'setup expect' '
1441
+cat >expected <<EOF
1442
+TG9vaywgSSBoYXZlIGEgQ1JMRiBhbmQgYW4gPSBzaWduIQ0K
1443
+EOF
1444
+'
1445
+
1446
+test_expect_success $PREREQ 'CRLF and sendemail.transferencoding=base64' '
1447
+ clean_fake_sendmail &&
1448
+ git send-email \
1449
+ --transfer-encoding=base64 \
1450
+ --smtp-server="$(pwd)/fake.sendmail" \
1451
+ email-using-crlf \
1452
+ 2>errors >out &&
1453
+ sed '1,/^$/d' msgtxt1 >actual &&
1454
+ test_cmp expected actual
1455
+'
1456
+
1457
+
1458
# Note that the patches in this test are deliberately out of order; we
1459
# want to make sure it works even if the cover-letter is not in the
1460
# first mail.