summaryrefslogtreecommitdiffstats
path: root/subcmds/rebase.py
diff options
context:
space:
mode:
authorJoe Hansche <jhansche@myyearbook.com>2012-03-05 11:41:19 -0500
committerShawn O. Pearce <sop@google.com>2012-06-13 10:34:41 -0700
commit5e57234ec619d0de930333a8dde3004d1dc575d6 (patch)
tree40f4eab3f13e5b4a1ca4ff3f501539ae63f44229 /subcmds/rebase.py
parent5d016502ebc68bc054d85c98c6cdb51e0b63a1f5 (diff)
downloadgit-repo-5e57234ec619d0de930333a8dde3004d1dc575d6.tar.gz
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
Diffstat (limited to 'subcmds/rebase.py')
-rw-r--r--subcmds/rebase.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index 7c8e9389..20662b11 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -52,6 +52,9 @@ branch but need to incorporate new upstream changes "underneath" them.
52 p.add_option('--whitespace', 52 p.add_option('--whitespace',
53 dest='whitespace', action='store', metavar='WS', 53 dest='whitespace', action='store', metavar='WS',
54 help='Pass --whitespace to git rebase') 54 help='Pass --whitespace to git rebase')
55 p.add_option('--auto-stash',
56 dest='auto_stash', action='store_true',
57 help='Stash local modifications before starting')
55 58
56 def Execute(self, opt, args): 59 def Execute(self, opt, args):
57 all = self.GetProjects(args) 60 all = self.GetProjects(args)
@@ -103,5 +106,23 @@ branch but need to incorporate new upstream changes "underneath" them.
103 print >>sys.stderr, '# %s: rebasing %s -> %s' % \ 106 print >>sys.stderr, '# %s: rebasing %s -> %s' % \
104 (project.relpath, cb, upbranch.LocalMerge) 107 (project.relpath, cb, upbranch.LocalMerge)
105 108
109 needs_stash = False
110 if opt.auto_stash:
111 stash_args = ["update-index", "--refresh", "-q"]
112
113 if GitCommand(project, stash_args).Wait() != 0:
114 needs_stash = True
115 # Dirty index, requires stash...
116 stash_args = ["stash"]
117
118 if GitCommand(project, stash_args).Wait() != 0:
119 return -1
120
106 if GitCommand(project, args).Wait() != 0: 121 if GitCommand(project, args).Wait() != 0:
107 return -1 122 return -1
123
124 if needs_stash:
125 stash_args.append('pop')
126 stash_args.append('--quiet')
127 if GitCommand(project, stash_args).Wait() != 0:
128 return -1