[PATCH 1/2] patman: Make sure sendemail.suppresscc is (un)set correctly

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 ---
tools/patman/gitutil.py | 25 +++++++++++++++++++++++++ tools/patman/main.py | 2 ++ 2 files changed, 27 insertions(+)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 5189840eab..022cc6416a 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -333,6 +333,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): diff --git a/tools/patman/main.py b/tools/patman/main.py index 28a9a26087..a4aa5274c9 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -167,6 +167,8 @@ else: not options.ignore_bad_tags, options.add_maintainers, options.limit)
+ ok = ok and gitutil.CheckSuppressCCConfig() + # Email the patches out (giving the user time to check / cancel) cmd = '' its_a_go = ok or options.ignore_errors

The user can either count the number of patches, or provide a tracking branch.
Signed-off-by: Nicolas Boichat drinkcat@chromium.org ---
tools/patman/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/patman/main.py b/tools/patman/main.py index a4aa5274c9..2e6ad48c6a 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -140,7 +140,8 @@ else:
col = terminal.Color() if not options.count: - str = 'No commits found to process - please use -c flag' + str = 'No commits found to process - please use -c flag, or run:\n' \ + ' git branch --set-upstream-to remote/branch' sys.exit(col.Color(col.RED, str))
# Read the metadata from the commits

On Sun, 12 Jul 2020 at 20:50, Nicolas Boichat drinkcat@chromium.org wrote:
The user can either count the number of patches, or provide a tracking branch.
Signed-off-by: Nicolas Boichat drinkcat@chromium.org
tools/patman/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, 12 Jul 2020 at 20:50, Nicolas Boichat drinkcat@chromium.org wrote:
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
tools/patman/gitutil.py | 25 +++++++++++++++++++++++++ tools/patman/main.py | 2 ++ 2 files changed, 27 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
participants (2)
-
Nicolas Boichat
-
Simon Glass