Permalink
Browse files

rebase: Pass through more options

Passing through --whitespace=fix to rebase can be useful
to clean up a branch prior to uploading it for review.

Change-Id: Id85f1912e5e11ff9602e3b342c2fd7441abe67d7
Signed-off-by: Shawn O. Pearce <sop@google.com>
  • Loading branch information...
1 parent 3575b8f commit a22f99ae41a9cdda2129c89678a6f581b0445c85 @spearce spearce committed Jul 16, 2010
Showing with 39 additions and 7 deletions.
  1. +39 −7 subcmds/rebase.py
View
@@ -37,6 +37,22 @@ def _Options(self, p):
dest="interactive", action="store_true",
help="interactive rebase (single project only)")
+ p.add_option('-f', '--force-rebase',
+ dest='force_rebase', action='store_true',
+ help='Pass --force-rebase to git rebase')
+ p.add_option('--no-ff',
+ dest='no_ff', action='store_true',
+ help='Pass --no-ff to git rebase')
+ p.add_option('-q', '--quiet',
+ dest='quiet', action='store_true',
+ help='Pass --quiet to git rebase')
+ p.add_option('--autosquash',
+ dest='autosquash', action='store_true',
+ help='Pass --autosquash to git rebase')
+ p.add_option('--whitespace',
+ dest='whitespace', action='store', metavar='WS',
+ help='Pass --whitespace to git rebase')
+
def Execute(self, opt, args):
all = self.GetProjects(args)
one_project = len(all) == 1
@@ -49,27 +65,43 @@ def Execute(self, opt, args):
cb = project.CurrentBranch
if not cb:
if one_project:
- print >>sys.stderr, "error: project %s has a detatched HEAD" % project.name
+ print >>sys.stderr, "error: project %s has a detatched HEAD" % project.relpath
return -1
# ignore branches with detatched HEADs
continue
upbranch = project.GetBranch(cb)
if not upbranch.LocalMerge:
if one_project:
- print >>sys.stderr, "error: project %s does not track any remote branches" % project.name
+ print >>sys.stderr, "error: project %s does not track any remote branches" % project.relpath
return -1
# ignore branches without remotes
continue
- upstream = project.GetRevisionId()
-
args = ["rebase"]
+
+ if opt.whitespace:
+ args.append('--whitespace=%s' % opt.whitespace)
+
+ if opt.quiet:
+ args.append('--quiet')
+
+ if opt.force_rebase:
+ args.append('--force-rebase')
+
+ if opt.no_ff:
+ args.append('--no-ff')
+
+ if opt.autosquash:
+ args.append('--autosquash')
+
if opt.interactive:
args.append("-i")
- args.append(upstream)
- print '# project %s: rebasing branch %s -> %s (%s)' % (
- project.relpath, cb, upbranch.LocalMerge, upstream[0:7])
+ args.append(upbranch.LocalMerge)
+
+ print >>sys.stderr, '# %s: rebasing %s -> %s' % \
+ (project.relpath, cb, upbranch.LocalMerge)
+
if GitCommand(project, args).Wait() != 0:
return -1

0 comments on commit a22f99a

Please sign in to comment.