diff --git a/gclient.py b/gclient.py index 22a4eb96a..5f9dac5c5 100755 --- a/gclient.py +++ b/gclient.py @@ -2003,6 +2003,9 @@ def CMDsync(parser, args): parser.add_option('-M', '--merge', action='store_true', help='merge upstream changes instead of trying to ' 'fast-forward or rebase') + parser.add_option('-A', '--auto_rebase', action='store_true', + help='Automatically rebase repositories against local ' + 'checkout during update (git only).') parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', help='override deps for the specified (comma-separated) ' 'platform(s); \'all\' will process all deps_os ' diff --git a/gclient_scm.py b/gclient_scm.py index 243387b6a..24064f92b 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -606,15 +606,16 @@ class GitWrapper(SCMWrapper): self.Print('_____ %s%s' % (self.relpath, rev_str), timestamp=False) printed_path = True while True: - try: - action = self._AskForData( - 'Cannot %s, attempt to rebase? ' - '(y)es / (q)uit / (s)kip : ' % - ('merge' if options.merge else 'fast-forward merge'), - options) - except ValueError: - raise gclient_utils.Error('Invalid Character') - if re.match(r'yes|y', action, re.I): + if not options.auto_rebase: + try: + action = self._AskForData( + 'Cannot %s, attempt to rebase? ' + '(y)es / (q)uit / (s)kip : ' % + ('merge' if options.merge else 'fast-forward merge'), + options) + except ValueError: + raise gclient_utils.Error('Invalid Character') + if options.auto_rebase or re.match(r'yes|y', action, re.I): self._AttemptRebase(upstream_branch, files, options, printed_path=printed_path, merge=False) printed_path = True diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 967d3606e..03a87fd75 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -804,6 +804,7 @@ class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils, """This class doesn't use pymox.""" class OptionsObject(object): def __init__(self, verbose=False, revision=None): + self.auto_rebase = False self.verbose = verbose self.revision = revision self.manually_grab_svn_rev = True