mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Support automatically stashing local modifications during repo-rebase.
Currently repo-rebase requires that all modifications be committed locally before it will allow the rebase. In high-velocity environments, you may want to just pull in newer code without explicitly creating local commits, which is typically achieved using git-stash. If called with the --auto-stash command line argument, and it is determined that the current index is dirty, the local modifications are stashed, and the rebase continues. If a stash was performed, that stash is popped once the rebase completes. Note that there is still a possibility that the git-stash pop will result in a merge conflict. Change-Id: Ibe3da96f0b4486cb7ce8d040639187e26501f6af
This commit is contained in:
parent
5d016502eb
commit
5e57234ec6
@ -52,6 +52,9 @@ branch but need to incorporate new upstream changes "underneath" them.
|
||||
p.add_option('--whitespace',
|
||||
dest='whitespace', action='store', metavar='WS',
|
||||
help='Pass --whitespace to git rebase')
|
||||
p.add_option('--auto-stash',
|
||||
dest='auto_stash', action='store_true',
|
||||
help='Stash local modifications before starting')
|
||||
|
||||
def Execute(self, opt, args):
|
||||
all = self.GetProjects(args)
|
||||
@ -103,5 +106,23 @@ branch but need to incorporate new upstream changes "underneath" them.
|
||||
print >>sys.stderr, '# %s: rebasing %s -> %s' % \
|
||||
(project.relpath, cb, upbranch.LocalMerge)
|
||||
|
||||
needs_stash = False
|
||||
if opt.auto_stash:
|
||||
stash_args = ["update-index", "--refresh", "-q"]
|
||||
|
||||
if GitCommand(project, stash_args).Wait() != 0:
|
||||
needs_stash = True
|
||||
# Dirty index, requires stash...
|
||||
stash_args = ["stash"]
|
||||
|
||||
if GitCommand(project, stash_args).Wait() != 0:
|
||||
return -1
|
||||
|
||||
if GitCommand(project, args).Wait() != 0:
|
||||
return -1
|
||||
|
||||
if needs_stash:
|
||||
stash_args.append('pop')
|
||||
stash_args.append('--quiet')
|
||||
if GitCommand(project, stash_args).Wait() != 0:
|
||||
return -1
|
||||
|
Loading…
Reference in New Issue
Block a user