summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-13 12:31:13 -0800
committerJunio C Hamano <gitster@pobox.com>2010-01-13 12:31:13 -0800
commit1f73566af5bec28cd8489c6139a9ede95817349c (patch)
treeb1deca9888bc171d09420d927bbe694795cf5d83 /git-rebase.sh
parent5b9c0a699bdf9727d25eceb7b980dbede96bfd8e (diff)
parent230a4566382860fc26a3f8d578a41c6504cf865f (diff)
downloadgit-1f73566af5bec28cd8489c6139a9ede95817349c.tar.gz
Merge branch 'jc/checkout-merge-base'
* jc/checkout-merge-base: rebase -i: teach --onto A...B syntax rebase: fix --onto A...B parsing and add tests "rebase --onto A...B" replays history on the merge base between A and B "checkout A...B" switches to the merge base between A and B
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh24
1 files changed, 23 insertions, 1 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index b121f4537c..3de0942c0f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -34,6 +34,8 @@ set_reflog_action rebase
require_work_tree
cd_to_toplevel
+LF='
+'
OK_TO_SKIP_PRE_REBASE=
RESOLVEMSG="
When you have resolved this problem run \"git rebase --continue\".
@@ -417,7 +419,27 @@ fi
# Make sure the branch to rebase onto is valid.
onto_name=${newbase-"$upstream_name"}
-onto=$(git rev-parse --verify "${onto_name}^0") || exit
+case "$onto_name" in
+*...*)
+ if left=${onto_name%...*} right=${onto_name#*...} &&
+ onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
+ then
+ case "$onto" in
+ ?*"$LF"?*)
+ die "$onto_name: there are more than one merge bases"
+ ;;
+ '')
+ die "$onto_name: there is no merge base"
+ ;;
+ esac
+ else
+ die "$onto_name: there is no merge base"
+ fi
+ ;;
+*)
+ onto=$(git rev-parse --verify "${onto_name}^0") || exit
+ ;;
+esac
# If a hook exists, give it a chance to interrupt
run_pre_rebase_hook "$upstream_arg" "$@"