summaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorNanako Shiraishi <nanako3@lavabit.com>2010-01-07 20:05:09 +0900
committerJunio C Hamano <gitster@pobox.com>2010-01-07 11:15:20 -0800
commit230a4566382860fc26a3f8d578a41c6504cf865f (patch)
tree00ccc093720791cc427e9a7b929f9ce5730483f9 /git-rebase--interactive.sh
parent9f21e97ddccf114a6919cf4b8cf57c2838328f36 (diff)
downloadgit-230a4566382860fc26a3f8d578a41c6504cf865f.tar.gz
rebase -i: teach --onto A...B syntax
When rewriting commits on a topic branch, sometimes it is easier to compare the version of commits before and after the rewrite if they are based on the same commit that forked from the upstream. An earlier commit by Junio (fixed up by the previous commit) gives "--onto A...B" syntax to rebase command, and rebases on top of the merge base between A and B; teach the same to the interactive version, too. Signed-off-by: しらいし ななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rwxr-xr-xgit-rebase--interactive.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 23ded48322..f7ae02ccb5 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -482,6 +482,25 @@ get_saved_options () {
test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
}
+LF='
+'
+parse_onto () {
+ case "$1" in
+ *...*)
+ if left=${1%...*} right=${1#*...} &&
+ onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
+ then
+ case "$onto" in
+ ?*"$LF"?* | '')
+ exit 1 ;;
+ esac
+ echo "$onto"
+ exit 0
+ fi
+ esac
+ git rev-parse --verify "$1^0"
+}
+
while test $# != 0
do
case "$1" in
@@ -589,7 +608,7 @@ first and then run 'git rebase --continue' again."
;;
--onto)
shift
- ONTO=$(git rev-parse --verify "$1") ||
+ ONTO=$(parse_onto "$1") ||
die "Does not point to a valid commit: $1"
;;
--)