patman: Make sure sendemail.suppresscc is (un)set correctly
authorNicolas Boichat <drinkcat@chromium.org>
Mon, 13 Jul 2020 02:50:00 +0000 (10:50 +0800)
committerSimon Glass <sjg@chromium.org>
Mon, 20 Jul 2020 17:37:47 +0000 (11:37 -0600)
Setting sendemail.suppresscc to all or cccmd leads to --cc-cmd
parameter being ignored, and emails going either nowhere, or
just to the To: line maintainer.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/patman/control.py
tools/patman/gitutil.py

index e67867b..8f4afea 100644 (file)
@@ -166,6 +166,8 @@ def send(args):
     ok = check_patches(series, patch_files, args.check_patch,
                        args.verbose)
 
+    ok = ok and gitutil.CheckSuppressCCConfig()
+
     its_a_go = ok or args.ignore_errors
     if its_a_go:
         email_patches(
index b683481..192d8e6 100644 (file)
@@ -344,6 +344,31 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
         return ['%s %s%s%s' % (tag, quote, email, quote) for email in result]
     return result
 
+def CheckSuppressCCConfig():
+    """Check if sendemail.suppresscc is configured correctly.
+
+    Returns:
+        True if the option is configured correctly, False otherwise.
+    """
+    suppresscc = command.OutputOneLine('git', 'config', 'sendemail.suppresscc',
+                                       raise_on_error=False)
+
+    # Other settings should be fine.
+    if suppresscc == 'all' or suppresscc == 'cccmd':
+        col = terminal.Color()
+
+        print((col.Color(col.RED, "error") +
+            ": git config sendemail.suppresscc set to %s\n"  % (suppresscc)) +
+            "  patman needs --cc-cmd to be run to set the cc list.\n" +
+            "  Please run:\n" +
+            "    git config --unset sendemail.suppresscc\n" +
+            "  Or read the man page:\n" +
+            "    git send-email --help\n" +
+            "  and set an option that runs --cc-cmd\n")
+        return False
+
+    return True
+
 def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
         self_only=False, alias=None, in_reply_to=None, thread=False,
         smtp_server=None):