# Extensions for the files involved in a three-way merge (ancestor,
# current, patched)
#extensions = .ancestor .current .patched
+
+[mail "alias"]
+ # E-mail aliases used with the 'mail' command
+ git = git@vger.kernel.org
return str_list[0]
+def address_or_alias(addr_str):
+ """Return the address if it contains an e-mail address or look up
+ the aliases in the config files.
+ """
+ def __address_or_alias(addr):
+ if addr.find('@') >= 0:
+ # it's an e-mail address
+ return addr
+ if config.has_option('mail "alias"', addr):
+ # it's an alias
+ return config.get('mail "alias"', addr)
+
+ raise CmdException, 'unknown e-mail alias: %s' % addr
+
+ addr_list = [__address_or_alias(addr.strip())
+ for addr in addr_str.split(',')]
+ return ', '.join(addr_list)
+
def patch_name_from_msg(msg):
"""Return a string to be used as a patch name. This is generated
from the first 30 characters of the top line of the string passed
configuration option. The From address and the e-mail format are
generated from the template file passed as argument to '--template'
(defaulting to '.git/patchmail.tmpl' or
-'~/.stgit/templates/patchmail.tmpl' or or
-'/usr/share/stgit/templates/patchmail.tmpl'). The To/Cc/Bcc addresses
-can either be added to the template file or passed via the
-corresponding command line options.
+'~/.stgit/templates/patchmail.tmpl' or
+'/usr/share/stgit/templates/patchmail.tmpl').
+
+The To/Cc/Bcc addresses can either be added to the template file or
+passed via the corresponding command line options. They can be e-mail
+addresses or aliases which are automatically expanded to the values
+stored in the [mail "alias"] section of GIT configuration files.
A preamble e-mail can be sent using the '--cover' and/or
'--edit-cover' options. The first allows the user to specify a file to
if not sender:
raise CmdException, 'unknown sender details'
- return sender
+ return address_or_alias(sender)
def __parse_addresses(addresses):
"""Return a two elements tuple: (from, [to])
del msg[header]
if crt_addr:
- msg[header] = ', '.join([crt_addr, addr])
+ msg[header] = address_or_alias(', '.join([crt_addr, addr]))
else:
- msg[header] = addr
+ msg[header] = address_or_alias(addr)
to_addr = ''
cc_addr = ''