diff --git a/git_cl.py b/git_cl.py index 35767c19d..9be92158e 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1504,8 +1504,9 @@ class Changelist(object): return change_description def _GetTitleForUpload(self, options): - # When not squashing, just return options.title. - if not options.squash: + # When not squashing or options.title is provided, just return + # options.title. + if not options.squash or options.title: return options.title # On first upload, patchset title is always this string, while options.title @@ -1515,8 +1516,6 @@ class Changelist(object): # When uploading subsequent patchsets, options.message is taken as the title # if options.title is not provided. - if options.title: - return options.title if options.message: return options.message.strip() diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index e08a8507d..0c72c274c 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -878,11 +878,11 @@ class TestGitCl(unittest.TestCase): metrics_arguments.append('notify=NONE') # If issue is given, then description is fetched from Gerrit instead. - if issue is None: - if squash: - title = 'Initial upload' - else: - if not title: + if not title: + if issue is None: + if squash: + title = 'Initial upload' + else: calls += [ ((['git', 'show', '-s', '--format=%s', 'HEAD'],), ''), (('ask_for_data', 'Title for patchset []: '), 'User input'), @@ -1378,6 +1378,7 @@ class TestGitCl(unittest.TestCase): ['-f', '-t', 'title'], 'title\n\ndesc\n\nChange-Id: 123456789', [], + title='title', force=True, squash=True, log_description='desc',