Merge branch 'stable'
[stgit] / stgit / commands / mail.py
index 2dd88c3..46e4b55 100644 (file)
@@ -154,9 +154,14 @@ def __get_sender():
         try:
             sender = str(git.user())
         except git.GitException:
-            sender = str(git.author())
+            try:
+                sender = str(git.author())
+            except git.GitException:
+                pass
     if not sender:
-        raise CmdException, 'unknown sender details'
+        raise CmdException, ('Unknown sender name and e-mail; you should'
+                             ' for example set git config user.name and'
+                             ' user.email')
     sender = email.Utils.parseaddr(sender)
 
     return email.Utils.formataddr(address_or_alias(sender))
@@ -399,7 +404,8 @@ def __build_cover(tmpl, patches, msg_id, options):
                                                 for p in patches),
                  'diffstat':     gitlib.diffstat(git.diff(
                      rev1 = git_id(crt_series, '%s^' % patches[0]),
-                     rev2 = git_id(crt_series, '%s' % patches[-1])))}
+                     rev2 = git_id(crt_series, '%s' % patches[-1]),
+                     diff_flags = options.diff_flags))}
 
     try:
         msg_string = tmpl % tmpl_dict
@@ -551,6 +557,9 @@ def func(parser, options, args):
     else:
         raise CmdException, 'Incorrect options. Unknown patches to send'
 
+    # early test for sender identity
+    __get_sender()
+
     out.start('Checking the validity of the patches')
     for p in patches:
         if crt_series.empty_patch(p):