]> Pileus Git - ~andy/git/blobdiff - git-rebase.sh
git-remote-mediawiki: show progress information when getting last remote revision
[~andy/git] / git-rebase.sh
index 6bd8eae6480033b353d1d86403fc9f2067d8e502..1cd0633b80a8daf00dbc50657ccba228bd578a73 100755 (executable)
@@ -32,7 +32,7 @@ SUBDIRECTORY_OK=Yes
 OPTIONS_KEEPDASHDASH=
 OPTIONS_SPEC="\
 git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
-git rebase [-i] [options] [--exec <cmd>] --onto <newbase> --root [<branch>]
+git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
 git-rebase [-i] --continue | --abort | --skip
 --
  Available options are
@@ -378,6 +378,11 @@ and run me again.  I am stopping in case you still have something
 valuable there.'
 fi
 
+if test -n "$rebase_root" && test -z "$onto"
+then
+       test -z "$interactive_rebase" && interactive_rebase=implied
+fi
+
 if test -n "$interactive_rebase"
 then
        type=interactive
@@ -411,9 +416,15 @@ then
        die "invalid upstream $upstream_name"
        upstream_arg="$upstream_name"
 else
-       test -z "$onto" && die "You must specify --onto when using --root"
+       if test -z "$onto"
+       then
+               empty_tree=`git hash-object -t tree /dev/null`
+               onto=`git commit-tree $empty_tree </dev/null`
+               squash_onto="$onto"
+       fi
        unset upstream_name
        unset upstream
+       test $# -gt 1 && usage
        upstream_arg=--root
 fi
 
@@ -464,7 +475,7 @@ case "$#" in
                die "fatal: no such branch: $1"
        fi
        ;;
-*)
+0)
        # Do not need to switch branches, we are already on it.
        if branch_name=`git symbolic-ref -q HEAD`
        then
@@ -476,6 +487,9 @@ case "$#" in
        fi
        orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
        ;;
+*)
+       die "BUG: unexpected number of arguments left to parse"
+       ;;
 esac
 
 require_clean_work_tree "rebase" "Please commit or stash them."