]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5100-mailinfo.sh
GIT 1.6.5
[thirdparty/git.git] / t / t5100-mailinfo.sh
CommitLineData
4839c0b5
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
5be60078 6test_description='git mailinfo and git mailsplit test'
4839c0b5
JH
7
8. ./test-lib.sh
9
10test_expect_success 'split sample box' \
bfdbee98 11 'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last &&
4839c0b5
JH
12 last=`cat last` &&
13 echo total is $last &&
200c75f0 14 test `cat last` = 14'
4839c0b5 15
017678b4
JH
16check_mailinfo () {
17 mail=$1 opt=$2
18 mo="$mail$opt"
19 git mailinfo -u $opt msg$mo patch$mo <$mail >info$mo &&
20 test_cmp "$TEST_DIRECTORY"/t5100/msg$mo msg$mo &&
21 test_cmp "$TEST_DIRECTORY"/t5100/patch$mo patch$mo &&
22 test_cmp "$TEST_DIRECTORY"/t5100/info$mo info$mo
23}
24
25
4839c0b5
JH
26for mail in `echo 00*`
27do
bfdbee98 28 test_expect_success "mailinfo $mail" '
017678b4
JH
29 check_mailinfo $mail "" &&
30 if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors
31 then
32 check_mailinfo $mail --scissors
33 fi
bfdbee98 34 '
4839c0b5
JH
35done
36
c32815f9
KS
37
38test_expect_success 'split box with rfc2047 samples' \
39 'mkdir rfc2047 &&
40 git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \
41 >rfc2047/last &&
42 last=`cat rfc2047/last` &&
43 echo total is $last &&
44 test `cat rfc2047/last` = 11'
45
46for mail in `echo rfc2047/00*`
47do
48 test_expect_success "mailinfo $mail" '
49 git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info &&
50 echo msg &&
51 test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg &&
52 echo patch &&
53 test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch &&
54 echo info &&
55 test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info
56 '
57done
58
cce8d6fd
JS
59test_expect_success 'respect NULs' '
60
bfdbee98
JH
61 git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain &&
62 test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
cce8d6fd
JS
63 (cat 001 | git mailinfo msg patch) &&
64 test 4 = $(wc -l < patch)
65
66'
67
9aa23094
JH
68test_expect_success 'Preserve NULs out of MIME encoded message' '
69
bfdbee98
JH
70 git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in &&
71 test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 &&
9aa23094 72 git mailinfo msg patch <00001 &&
bfdbee98 73 test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch
9aa23094
JH
74
75'
76
e9d7d10a
JK
77test_expect_success 'mailinfo on from header without name works' '
78
79 mkdir info-from &&
80 git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in &&
81 test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 &&
82 git mailinfo info-from/msg info-from/patch \
83 <info-from/0001 >info-from/out &&
84 test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out
85
86'
87
4839c0b5 88test_done