aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@gmail.com>2010-10-22 16:44:13 +0100
committerCatalin Marinas <catalin.marinas@gmail.com>2010-10-22 16:44:13 +0100
commit2034b19ee1787725164e695cffa6d50384ef8cb1 (patch)
tree7a29de6a9bd002e6b6d8879a6ca5546de0f835ef
parent32a4e200ade6693f98cab1118d9088d4049a65c3 (diff)
downloadstgit-2034b19ee1787725164e695cffa6d50384ef8cb1.tar.gz
Allow uncommitting to a common ancestor
With the --to=<commit> option to uncommit, if the given commit is not in the history just try to find the common ancestor and uncommit to that point (exclusive range). Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r--stgit/commands/uncommit.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/stgit/commands/uncommit.py b/stgit/commands/uncommit.py
index 72ba88c..f303b7f 100644
--- a/stgit/commands/uncommit.py
+++ b/stgit/commands/uncommit.py
@@ -71,6 +71,11 @@ def func(parser, options, args):
parser.error('cannot specify patch name with --to')
patch_nr = patchnames = None
to_commit = stack.repository.rev_parse(options.to)
+ # check whether the --to commit is on a different branch
+ merge_bases = directory.repository.get_merge_bases(to_commit, stack.base)
+ if not to_commit in merge_bases:
+ to_commit = merge_bases[0]
+ options.exclusive = True
elif options.number:
if options.number <= 0:
parser.error('invalid value passed to --number')