]>
Commit | Line | Data |
---|---|---|
fa21b602 JK |
1 | #!/bin/sh |
2 | ||
5be60078 | 3 | test_description='git rev-list --pretty=format test' |
fa21b602 JK |
4 | |
5 | . ./test-lib.sh | |
6 | ||
7 | test_tick | |
8 | test_expect_success 'setup' ' | |
5be60078 | 9 | touch foo && git add foo && git-commit -m "added foo" && |
fa21b602 JK |
10 | echo changed >foo && git-commit -a -m "changed foo" |
11 | ' | |
12 | ||
13 | # usage: test_format name format_string <expected_output | |
14 | test_format() { | |
15 | cat >expect.$1 | |
16 | test_expect_success "format $1" " | |
5be60078 | 17 | git rev-list --pretty=format:$2 master >output.$1 && |
3af82863 | 18 | test_cmp expect.$1 output.$1 |
fa21b602 JK |
19 | " |
20 | } | |
21 | ||
22 | test_format hash %H%n%h <<'EOF' | |
23 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
24 | 131a310eb913d107dd3c09a65d1651175898735d | |
25 | 131a310 | |
26 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
27 | 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
28 | 86c75cf | |
29 | EOF | |
30 | ||
31 | test_format tree %T%n%t <<'EOF' | |
32 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
33 | fe722612f26da5064c32ca3843aa154bdb0b08a0 | |
34 | fe72261 | |
35 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
36 | 4d5fcadc293a348e88f777dc0920f11e7d71441c | |
37 | 4d5fcad | |
38 | EOF | |
39 | ||
40 | test_format parents %P%n%p <<'EOF' | |
41 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
542e165c JH |
42 | 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
43 | 86c75cf | |
fa21b602 | 44 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
542e165c JH |
45 | |
46 | ||
fa21b602 JK |
47 | EOF |
48 | ||
49 | # we don't test relative here | |
50 | test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF' | |
51 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
52 | A U Thor | |
53 | author@example.com | |
54 | Thu Apr 7 15:13:13 2005 -0700 | |
55 | Thu, 7 Apr 2005 15:13:13 -0700 | |
56 | 1112911993 | |
57 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
58 | A U Thor | |
59 | author@example.com | |
60 | Thu Apr 7 15:13:13 2005 -0700 | |
61 | Thu, 7 Apr 2005 15:13:13 -0700 | |
62 | 1112911993 | |
63 | EOF | |
64 | ||
65 | test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF' | |
66 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
67 | C O Mitter | |
68 | committer@example.com | |
69 | Thu Apr 7 15:13:13 2005 -0700 | |
70 | Thu, 7 Apr 2005 15:13:13 -0700 | |
71 | 1112911993 | |
72 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
73 | C O Mitter | |
74 | committer@example.com | |
75 | Thu Apr 7 15:13:13 2005 -0700 | |
76 | Thu, 7 Apr 2005 15:13:13 -0700 | |
77 | 1112911993 | |
78 | EOF | |
79 | ||
80 | test_format encoding %e <<'EOF' | |
81 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
fa21b602 | 82 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
fa21b602 JK |
83 | EOF |
84 | ||
85 | test_format subject %s <<'EOF' | |
86 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
87 | changed foo | |
88 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
89 | added foo | |
90 | EOF | |
91 | ||
92 | test_format body %b <<'EOF' | |
93 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
fa21b602 | 94 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
fa21b602 JK |
95 | EOF |
96 | ||
97 | test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF' | |
98 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
99 | \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy | |
100 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
101 | \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy | |
102 | EOF | |
103 | ||
03bcaaca JK |
104 | cat >commit-msg <<'EOF' |
105 | Test printing of complex bodies | |
106 | ||
107 | This commit message is much longer than the others, | |
108 | and it will be encoded in iso8859-1. We should therefore | |
109 | include an iso8859 character: ¡bueno! | |
110 | EOF | |
111 | test_expect_success 'setup complex body' ' | |
5be60078 | 112 | git config i18n.commitencoding iso8859-1 && |
03bcaaca JK |
113 | echo change2 >foo && git-commit -a -F commit-msg |
114 | ' | |
115 | ||
116 | test_format complex-encoding %e <<'EOF' | |
117 | commit f58db70b055c5718631e5c61528b28b12090cdea | |
118 | iso8859-1 | |
119 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
03bcaaca | 120 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
03bcaaca JK |
121 | EOF |
122 | ||
123 | test_format complex-subject %s <<'EOF' | |
124 | commit f58db70b055c5718631e5c61528b28b12090cdea | |
125 | Test printing of complex bodies | |
126 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
127 | changed foo | |
128 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 | |
129 | added foo | |
130 | EOF | |
131 | ||
132 | test_format complex-body %b <<'EOF' | |
133 | commit f58db70b055c5718631e5c61528b28b12090cdea | |
134 | This commit message is much longer than the others, | |
135 | and it will be encoded in iso8859-1. We should therefore | |
136 | include an iso8859 character: ¡bueno! | |
137 | ||
138 | commit 131a310eb913d107dd3c09a65d1651175898735d | |
03bcaaca | 139 | commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 |
03bcaaca JK |
140 | EOF |
141 | ||
f7ab5c79 JH |
142 | test_expect_success 'empty email' ' |
143 | test_tick && | |
144 | C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) && | |
145 | A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) && | |
146 | test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" || { | |
147 | echo "Eh? $A" >failure | |
148 | false | |
149 | } | |
150 | ' | |
151 | ||
fa21b602 | 152 | test_done |