summaryrefslogtreecommitdiffstats
path: root/subcmds/rebase.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/rebase.py')
-rw-r--r--subcmds/rebase.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/subcmds/rebase.py b/subcmds/rebase.py
index e341296d..20662b11 100644
--- a/subcmds/rebase.py
+++ b/subcmds/rebase.py
@@ -17,7 +17,7 @@ import sys
17 17
18from command import Command 18from command import Command
19from git_command import GitCommand 19from git_command import GitCommand
20from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB 20from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M
21from error import GitError 21from error import GitError
22 22
23class Rebase(Command): 23class Rebase(Command):
@@ -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