mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
3575b8f8bd
commit
a22f99ae41
@ -37,6 +37,22 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
dest="interactive", action="store_true",
|
dest="interactive", action="store_true",
|
||||||
help="interactive rebase (single project only)")
|
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):
|
def Execute(self, opt, args):
|
||||||
all = self.GetProjects(args)
|
all = self.GetProjects(args)
|
||||||
one_project = len(all) == 1
|
one_project = len(all) == 1
|
||||||
@ -49,7 +65,7 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
cb = project.CurrentBranch
|
cb = project.CurrentBranch
|
||||||
if not cb:
|
if not cb:
|
||||||
if one_project:
|
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
|
return -1
|
||||||
# ignore branches with detatched HEADs
|
# ignore branches with detatched HEADs
|
||||||
continue
|
continue
|
||||||
@ -57,19 +73,35 @@ branch but need to incorporate new upstream changes "underneath" them.
|
|||||||
upbranch = project.GetBranch(cb)
|
upbranch = project.GetBranch(cb)
|
||||||
if not upbranch.LocalMerge:
|
if not upbranch.LocalMerge:
|
||||||
if one_project:
|
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
|
return -1
|
||||||
# ignore branches without remotes
|
# ignore branches without remotes
|
||||||
continue
|
continue
|
||||||
|
|
||||||
upstream = project.GetRevisionId()
|
|
||||||
|
|
||||||
args = ["rebase"]
|
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:
|
if opt.interactive:
|
||||||
args.append("-i")
|
args.append("-i")
|
||||||
args.append(upstream)
|
|
||||||
|
|
||||||
print '# project %s: rebasing branch %s -> %s (%s)' % (
|
args.append(upbranch.LocalMerge)
|
||||||
project.relpath, cb, upbranch.LocalMerge, upstream[0:7])
|
|
||||||
|
print >>sys.stderr, '# %s: rebasing %s -> %s' % \
|
||||||
|
(project.relpath, cb, upbranch.LocalMerge)
|
||||||
|
|
||||||
if GitCommand(project, args).Wait() != 0:
|
if GitCommand(project, args).Wait() != 0:
|
||||||
return -1
|
return -1
|
||||||
|
Loading…
Reference in New Issue
Block a user