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