- print 'Pulling from "%s"...' % repository
- git.fetch(repository)
- if (config.get('stgit.pull-does-rebase') == 'yes'):
- fetch_head = git.fetch_head()
- if fetch_head != git.get_head():
- print 'rebasing to "%s"...' % fetch_head
- git.reset(tree_id = fetch_head)
- print 'done'
-
- # push the patches back
- if not options.nopush:
- push_patches(applied, options.merged)
+ if policy == 'pull':
+ out.info('Pulling from "%s"' % repository)
+ git.pull(repository)
+ elif policy == 'fetch-rebase':
+ out.info('Fetching from "%s"' % repository)
+ git.fetch(repository)
+ try:
+ target = git.fetch_head()
+ except git.GitException:
+ out.error('Could not find the remote head to rebase onto - fix branch.%s.merge in .git/config' % crt_series.get_name())
+ out.error('Pushing any patches back...')
+ post_rebase(crt_series, applied, False, False)
+ raise
+
+ rebase(crt_series, target)
+ elif policy == 'rebase':
+ rebase(crt_series, crt_series.get_parent_branch())
+
+ post_rebase(crt_series, applied, options.nopush, options.merged)