]> asedeno.scripts.mit.edu Git - git.git/blob - t/t4201-shortlog.sh
t4201 (shortlog): Test output format with multiple authors
[git.git] / t / t4201-shortlog.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Johannes E. Schindelin
4 #
5
6 test_description='git shortlog
7 '
8
9 . ./test-lib.sh
10
11 test_expect_success 'setup' '
12         echo 1 >a1 &&
13         git add a1 &&
14         tree=$(git write-tree) &&
15         commit=$(printf "%s\n" "Test" "" | git commit-tree "$tree") &&
16         git update-ref HEAD "$commit" &&
17
18         echo 2 >a1 &&
19         git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 &&
20
21         # test if the wrapping is still valid
22         # when replacing all is by treble clefs.
23         echo 3 >a1 &&
24         git commit --quiet -m "$(
25                 echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
26                 sed "s/i/1234/g" |
27                 tr 1234 "\360\235\204\236")" a1 &&
28
29         # now fsck up the utf8
30         git config i18n.commitencoding non-utf-8 &&
31         echo 4 >a1 &&
32         git commit --quiet -m "$(
33                 echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
34                 sed "s/i/1234/g" |
35                 tr 1234 "\370\235\204\236")" a1 &&
36
37         echo 5 >a1 &&
38         git commit --quiet -m "a                                                                12      34      56      78" a1
39
40         echo 6 >a1 &&
41         git commit --quiet -m "Commit by someone else" \
42                 --author="Someone else <not!me>" a1
43 '
44
45 test_expect_success 'shortlog wrapping' '
46         cat >expect <<\EOF &&
47 A U Thor (5):
48       Test
49       This is a very, very long first line for the commit message to see if
50          it is wrapped correctly
51       Th𝄞s 𝄞s a very, very long f𝄞rst l𝄞ne for the comm𝄞t message to see 𝄞f
52          𝄞t 𝄞s wrapped correctly
53       Thø\9d\84\9es ø\9d\84\9es a very, very long fø\9d\84\9erst lø\9d\84\9ene for the commø\9d\84\9et
54          message to see ø\9d\84\9ef ø\9d\84\9et ø\9d\84\9es wrapped correctly
55       a                                                         12      34
56          56     78
57
58 Someone else (1):
59       Commit by someone else
60
61 EOF
62         git shortlog -w HEAD >out &&
63         test_cmp expect out
64 '
65
66 test_expect_success 'shortlog from non-git directory' '
67         git log HEAD >log &&
68         GIT_DIR=non-existing git shortlog -w <log >out &&
69         test_cmp expect out
70 '
71
72 iconvfromutf8toiso88591() {
73         printf "%s" "$*" | iconv -f UTF-8 -t ISO8859-1
74 }
75
76 DSCHO="Jöhännës \"Dschö\" Schindëlin"
77 DSCHOE="$DSCHO <Johannes.Schindelin@gmx.de>"
78 MSG1="set a1 to 2 and some non-ASCII chars: Äßø"
79 MSG2="set a1 to 3 and some non-ASCII chars: áæï"
80 cat > expect << EOF
81 $DSCHO (2):
82       $MSG1
83       $MSG2
84
85 EOF
86
87 test_expect_success 'shortlog encoding' '
88         git reset --hard "$commit" &&
89         git config --unset i18n.commitencoding &&
90         echo 2 > a1 &&
91         git commit --quiet -m "$MSG1" --author="$DSCHOE" a1 &&
92         git config i18n.commitencoding "ISO8859-1" &&
93         echo 3 > a1 &&
94         git commit --quiet -m "$(iconvfromutf8toiso88591 "$MSG2")" \
95                 --author="$(iconvfromutf8toiso88591 "$DSCHOE")" a1 &&
96         git config --unset i18n.commitencoding &&
97         git shortlog HEAD~2.. > out &&
98 test_cmp expect out'
99
100 test_done