Only prompt for clean titles if manually set

We have to clean up the title, but if the user hasn't expressed any
input about the title (i.e. it's one we autogenerated), then don't
bother them by pointing it out.

BUG=684079

Change-Id: I8215e0a30f786466697fe1df178ca90e1980d9b0
Reviewed-on: https://chromium-review.googlesource.com/431162
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrew Bonventre <andybons@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index f18166f..3b92b90 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2653,6 +2653,7 @@
 
     # This may be None; default fallback value is determined in logic below.
     title = options.title
+    automatic_title = False
 
     if options.squash:
       self._GerritCommitMsgHookCheck(offer_removal=not options.force)
@@ -2667,6 +2668,8 @@
           default_title = RunGit(['show', '-s', '--format=%s', 'HEAD']).strip()
           title = ask_for_data(
               'Title for patchset [%s]: ' % default_title) or default_title
+          if title == default_title:
+            automatic_title = True
         change_id = self._GetChangeDetail()['change_id']
         while True:
           footer_change_ids = git_footers.get_footer_change_id(message)
@@ -2715,6 +2718,7 @@
         # On first upload, patchset title is always this string, while
         # --title flag gets converted to first line of message.
         title = 'Initial upload'
+        automatic_title = True
         if not change_desc.description:
           DieWithError("Description is empty. Aborting...")
         message = change_desc.description
@@ -2795,10 +2799,11 @@
     if title:
       if not re.match(r'^[\w ]+$', title):
         title = re.sub(r'[^\w ]', '', title)
-        print('WARNING: Patchset title may only contain alphanumeric chars '
-              'and spaces. Cleaned up title:\n%s' % title)
-        if not options.force:
-          ask_for_data('Press enter to continue, Ctrl+C to abort')
+        if not automatic_title:
+          print('WARNING: Patchset title may only contain alphanumeric chars '
+                'and spaces. Cleaned up title:\n%s' % title)
+          if not options.force:
+            ask_for_data('Press enter to continue, Ctrl+C to abort')
       # Per doc, spaces must be converted to underscores, and Gerrit will do the
       # reverse on its side.
       refspec_opts.append('m=' + title.replace(' ', '_'))