]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4201-shortlog.sh
hashmap: use *_entry APIs for iteration
[thirdparty/git.git] / t / t4201-shortlog.sh
CommitLineData
3714e7c8
JS
1#!/bin/sh
2#
3# Copyright (c) 2006 Johannes E. Schindelin
4#
5
5be60078 6test_description='git shortlog
3714e7c8
JS
7'
8
9. ./test-lib.sh
10
ae00dc19 11test_expect_success 'setup' '
5555a2aa 12 test_tick &&
ae00dc19
JN
13 echo 1 >a1 &&
14 git add a1 &&
15 tree=$(git write-tree) &&
16 commit=$(printf "%s\n" "Test" "" | git commit-tree "$tree") &&
17 git update-ref HEAD "$commit" &&
18
19 echo 2 >a1 &&
20 git commit --quiet -m "This is a very, very long first line for the commit message to see if it is wrapped correctly" a1 &&
21
22 # test if the wrapping is still valid
23 # when replacing all is by treble clefs.
24 echo 3 >a1 &&
25 git commit --quiet -m "$(
26 echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
27 sed "s/i/1234/g" |
28 tr 1234 "\360\235\204\236")" a1 &&
29
30 # now fsck up the utf8
31 git config i18n.commitencoding non-utf-8 &&
32 echo 4 >a1 &&
33 git commit --quiet -m "$(
34 echo "This is a very, very long first line for the commit message to see if it is wrapped correctly" |
35 sed "s/i/1234/g" |
36 tr 1234 "\370\235\204\236")" a1 &&
37
38 echo 5 >a1 &&
a48fcd83 39 git commit --quiet -m "a 12 34 56 78" a1 &&
ed715b5e
JN
40
41 echo 6 >a1 &&
42 git commit --quiet -m "Commit by someone else" \
60037249
JN
43 --author="Someone else <not!me>" a1 &&
44
45 cat >expect.template <<-\EOF
46 A U Thor (5):
47 SUBJECT
48 SUBJECT
49 SUBJECT
50 SUBJECT
51 SUBJECT
52
53 Someone else (1):
54 SUBJECT
55
56 EOF
57'
58
59fuzz() {
60 file=$1 &&
61 sed "
2ece6ad2 62 s/$OID_REGEX/OBJECT_NAME/g
5555a2aa 63 s/$_x35/OBJID/g
60037249
JN
64 s/^ \{6\}[CTa].*/ SUBJECT/g
65 s/^ \{8\}[^ ].*/ CONTINUATION/g
66 " <"$file" >"$file.fuzzy" &&
67 sed "/CONTINUATION/ d" <"$file.fuzzy"
68}
69
70test_expect_success 'default output format' '
71 git shortlog HEAD >log &&
72 fuzz log >log.predictable &&
73 test_cmp expect.template log.predictable
74'
75
76test_expect_success 'pretty format' '
77 sed s/SUBJECT/OBJECT_NAME/ expect.template >expect &&
78 git shortlog --format="%H" HEAD >log &&
79 fuzz log >log.predictable &&
80 test_cmp expect log.predictable
81'
82
c1977021 83test_expect_success '--abbrev' '
60037249 84 sed s/SUBJECT/OBJID/ expect.template >expect &&
5555a2aa 85 git shortlog --format="%h" --abbrev=35 HEAD >log &&
60037249
JN
86 fuzz log >log.predictable &&
87 test_cmp expect log.predictable
88'
89
90test_expect_success 'output from user-defined format is re-wrapped' '
91 sed "s/SUBJECT/two lines/" expect.template >expect &&
92 git shortlog --format="two%nlines" HEAD >log &&
93 fuzz log >log.predictable &&
94 test_cmp expect log.predictable
ae00dc19 95'
3714e7c8 96
f57a8715 97test_expect_success !MINGW 'shortlog wrapping' '
ae00dc19 98 cat >expect <<\EOF &&
3714e7c8
JS
99A U Thor (5):
100 Test
101 This is a very, very long first line for the commit message to see if
102 it is wrapped correctly
103 Th๐„žs ๐„žs a very, very long f๐„žrst l๐„žne for the comm๐„žt message to see ๐„žf
104 ๐„žt ๐„žs wrapped correctly
105