- if new_head == orig_head:
- print 'Branch already up-to-date'
- else:
- write_string(os.path.join(git.base_dir, 'ORIG_HEAD'), orig_head)
-
- applied = crt_series.get_applied()
-
- if len(applied) > 0:
- print 'Popping all patches...',
- sys.stdout.flush()
- crt_series.pop_patch(applied[0])
- print 'done'
-
- git.switch(new_head)
-
- if options.nopush:
- applied = []
- for p in applied:
- print 'Pushing patch "%s"...' % p,
- sys.stdout.flush()
- crt_series.push_patch(p)
- if crt_series.empty_patch(p):
- print 'done (empty patch)'
- else:
- print 'done'
+ # push the patches back
+ if not options.nopush:
+ push_patches(applied, options.merged)
+
+ # maybe tidy up
+ if config.get('stgit.keepoptimized') == 'yes':
+ git.repack()