git-svn: fix log with single revision against a non-HEAD branch
[git/dscho.git] / t / t6006-rev-list-format.sh
blobad6d0b8c9da56e22b22d4fd97898f20101964e1f
1 #!/bin/sh
3 test_description='git rev-list --pretty=format test'
5 . ./test-lib.sh
7 test_tick
8 test_expect_success 'setup' '
9 touch foo && git add foo && git-commit -m "added foo" &&
10 echo changed >foo && git-commit -a -m "changed foo"
13 # usage: test_format name format_string <expected_output
14 test_format() {
15 cat >expect.$1
16 test_expect_success "format $1" "
17 git rev-list --pretty=format:$2 master >output.$1 &&
18 git diff expect.$1 output.$1
22 test_format hash %H%n%h <<'EOF'
23 commit 131a310eb913d107dd3c09a65d1651175898735d
24 131a310eb913d107dd3c09a65d1651175898735d
25 131a310
26 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
27 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
28 86c75cf
29 EOF
31 test_format tree %T%n%t <<'EOF'
32 commit 131a310eb913d107dd3c09a65d1651175898735d
33 fe722612f26da5064c32ca3843aa154bdb0b08a0
34 fe72261
35 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
36 4d5fcadc293a348e88f777dc0920f11e7d71441c
37 4d5fcad
38 EOF
40 test_format parents %P%n%p <<'EOF'
41 commit 131a310eb913d107dd3c09a65d1651175898735d
42 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
43 86c75cf
44 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
47 EOF
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
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
80 test_format encoding %e <<'EOF'
81 commit 131a310eb913d107dd3c09a65d1651175898735d
82 <unknown>
83 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
84 <unknown>
85 EOF
87 test_format subject %s <<'EOF'
88 commit 131a310eb913d107dd3c09a65d1651175898735d
89 changed foo
90 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
91 added foo
92 EOF
94 test_format body %b <<'EOF'
95 commit 131a310eb913d107dd3c09a65d1651175898735d
96 <unknown>
97 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
98 <unknown>
99 EOF
101 test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
102 commit 131a310eb913d107dd3c09a65d1651175898735d
103 \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
104 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
105 \e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
108 cat >commit-msg <<'EOF'
109 Test printing of complex bodies
111 This commit message is much longer than the others,
112 and it will be encoded in iso8859-1. We should therefore
113 include an iso8859 character: ¡bueno!
115 test_expect_success 'setup complex body' '
116 git config i18n.commitencoding iso8859-1 &&
117 echo change2 >foo && git-commit -a -F commit-msg
120 test_format complex-encoding %e <<'EOF'
121 commit f58db70b055c5718631e5c61528b28b12090cdea
122 iso8859-1
123 commit 131a310eb913d107dd3c09a65d1651175898735d
124 <unknown>
125 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
126 <unknown>
129 test_format complex-subject %s <<'EOF'
130 commit f58db70b055c5718631e5c61528b28b12090cdea
131 Test printing of complex bodies
132 commit 131a310eb913d107dd3c09a65d1651175898735d
133 changed foo
134 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
135 added foo
138 test_format complex-body %b <<'EOF'
139 commit f58db70b055c5718631e5c61528b28b12090cdea
140 This commit message is much longer than the others,
141 and it will be encoded in iso8859-1. We should therefore
142 include an iso8859 character: ¡bueno!
144 commit 131a310eb913d107dd3c09a65d1651175898735d
145 <unknown>
146 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
147 <unknown>
150 test_done