@@ -2084,22 +2084,24 @@ test_dump_aliases '--dump-aliases mailrc format' \
2084
2084
' bob' \
2085
2085
' chloe' \
2086
2086
' eve' << -\EOF
2087
- alias alice Alice W Land <awol@example.com>
2088
- alias eve Eve <eve@example.com>
2089
- alias bob Robert Bobbyton <bob@example.com>
2087
+ alias alice " Alice W Land <awol@example.com>"
2088
+ alias eve " Eve <eve@example.com>"
2089
+ alias bob " Robert Bobbyton <bob@example.com>"
2090
2090
alias chloe chloe@example.com
2091
2091
EOF
2092
2092
2093
2093
test_dump_aliases ' --dump-aliases pine format' \
2094
2094
' pine' \
2095
2095
' alice' \
2096
+ ' bcgrp' \
2096
2097
' bob' \
2097
2098
' chloe' \
2098
2099
' eve' << -\EOF
2099
- alice Alice W Land < awol@example.com>
2100
- eve Eve < eve@example.com>
2101
- bob Robert Bobbyton < bob@example.com>
2100
+ alice Alice W Land awol@example.com Friend
2101
+ eve Eve eve@example.com
2102
+ bob Robert Bobbyton bob@example.com
2102
2103
chloe chloe@example.com
2104
+ bcgrp (bob, chloe, Other <o@example.com>)
2103
2105
EOF
2104
2106
2105
2107
test_dump_aliases ' --dump-aliases gnus format' \
@@ -2118,6 +2120,110 @@ test_expect_success '--dump-aliases must be used alone' '
2118
2120
test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
2119
2121
'
2120
2122
2123
+ test_translate_aliases () {
2124
+ msg=" $1 " && shift &&
2125
+ filetype=" $1 " && shift &&
2126
+ aliases=" $1 " && shift &&
2127
+ printf ' %s\n' " $@ " > expect &&
2128
+ cat > .tmp-email-aliases &&
2129
+ printf ' %s\n' " $aliases " > aliases &&
2130
+
2131
+ test_expect_success $PREREQ " $msg " '
2132
+ clean_fake_sendmail && rm -fr outdir &&
2133
+ git config --replace-all sendemail.aliasesfile \
2134
+ "$(pwd)/.tmp-email-aliases" &&
2135
+ git config sendemail.aliasfiletype "$filetype" &&
2136
+ git send-email --translate-aliases <aliases 2>errors >actual &&
2137
+ test_cmp expect actual
2138
+ '
2139
+ }
2140
+
2141
+ test_translate_aliases ' --translate-aliases sendmail format' \
2142
+ ' sendmail' \
2143
+ ' alice bcgrp' \
2144
+ ' Alice W Land <awol@example.com>' \
2145
+ ' Robert Bobbyton <bob@example.com>' \
2146
+ ' chloe@example.com' \
2147
+ ' Other <o@example.com>' << -\EOF
2148
+ alice: Alice W Land <awol@example.com>
2149
+ bob: Robert Bobbyton <bob@example.com>
2150
+ chloe: chloe@example.com
2151
+ abgroup: alice, bob
2152
+ bcgrp: bob, chloe, Other <o@example.com>
2153
+ EOF
2154
+
2155
+ test_translate_aliases ' --translate-aliases mutt format' \
2156
+ ' mutt' \
2157
+ ' donald bob' \
2158
+ ' Donald C Carlton <donc@example.com>' \
2159
+ ' Robert Bobbyton <bob@example.com>' << -\EOF
2160
+ alias alice Alice W Land <awol@example.com>
2161
+ alias donald Donald C Carlton <donc@example.com>
2162
+ alias bob Robert Bobbyton <bob@example.com>
2163
+ alias chloe chloe@example.com
2164
+ EOF
2165
+
2166
+ test_translate_aliases ' --translate-aliases mailrc format' \
2167
+ ' mailrc' \
2168
+ ' chloe eve alice' \
2169
+ ' chloe@example.com' \
2170
+ ' Eve <eve@example.com>' \
2171
+ ' Alice W Land <awol@example.com>' << -\EOF
2172
+ alias alice "Alice W Land <awol@example.com>"
2173
+ alias eve "Eve <eve@example.com>"
2174
+ alias bob "Robert Bobbyton <bob@example.com>"
2175
+ alias chloe chloe@example.com
2176
+ EOF
2177
+
2178
+ test_translate_aliases ' --translate-aliases pine format' \
2179
+ ' pine' \
2180
+ ' eve bob bcgrp' \
2181
+ ' eve@example.com' \
2182
+ ' bob@example.com' \
2183
+ ' bob@example.com' \
2184
+ ' chloe@example.com' \
2185
+ ' Other <o@example.com>' << -\EOF
2186
+ alice Alice W Land awol@example.com Friend
2187
+ eve Eve eve@example.com
2188
+ bob Robert Bobbyton bob@example.com
2189
+ chloe chloe@example.com
2190
+ bcgrp (bob, chloe, Other <o@example.com>)
2191
+ EOF
2192
+
2193
+ test_translate_aliases ' --translate-aliases gnus format' \
2194
+ ' gnus' \
2195
+ ' alice chloe eve' \
2196
+ ' awol@example.com' \
2197
+ ' chloe@example.com' \
2198
+ ' eve@example.com' << -\EOF
2199
+ (define-mail-alias "alice" "awol@example.com")
2200
+ (define-mail-alias "eve" "eve@example.com")
2201
+ (define-mail-alias "bob" "bob@example.com")
2202
+ (define-mail-alias "chloe" "chloe@example.com")
2203
+ EOF
2204
+
2205
+ test_expect_success $PREREQ ' --translate-aliases passes valid addresses through' '
2206
+ cat >expect <<-\EOF &&
2207
+ Other <o@example.com>
2208
+ EOF
2209
+ cat >aliases <<-\EOF &&
2210
+ Other <o@example.com>
2211
+ EOF
2212
+ git send-email --translate-aliases <aliases >actual &&
2213
+ test_cmp expect actual
2214
+ '
2215
+
2216
+ test_expect_success $PREREQ ' --translate-aliases passes unknown aliases through' '
2217
+ cat >expect <<-\EOF &&
2218
+ blargh
2219
+ EOF
2220
+ cat >aliases <<-\EOF &&
2221
+ blargh
2222
+ EOF
2223
+ git send-email --translate-aliases <aliases >actual &&
2224
+ test_cmp expect actual
2225
+ '
2226
+
2121
2227
test_expect_success $PREREQ ' aliases and sendemail.identity' '
2122
2228
test_must_fail git \
2123
2229
-c sendemail.identity=cloud \
0 commit comments