git-rebase--interactive.shon commit rebase-i-p: only list commits that require rewriting in todo (acc8559)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Johannes E. Schindelin
   4
   5# SHORT DESCRIPTION
   6#
   7# This script makes it easy to fix up commits in the middle of a series,
   8# and rearrange commits.
   9#
  10# The original idea comes from Eric W. Biederman, in
  11# http://article.gmane.org/gmane.comp.version-control.git/22407
  12
  13OPTIONS_KEEPDASHDASH=
  14OPTIONS_SPEC="\
  15git-rebase [-i] [options] [--] <upstream> [<branch>]
  16git-rebase [-i] (--continue | --abort | --skip)
  17--
  18 Available options are
  19v,verbose          display a diffstat of what changed upstream
  20onto=              rebase onto given branch instead of upstream
  21p,preserve-merges  try to recreate merges instead of ignoring them
  22s,strategy=        use the given merge strategy
  23m,merge            always used (no-op)
  24i,interactive      always used (no-op)
  25 Actions:
  26continue           continue rebasing process
  27abort              abort rebasing process and restore original branch
  28skip               skip current patch and continue rebasing process
  29"
  30
  31. git-sh-setup
  32require_work_tree
  33
  34DOTEST="$GIT_DIR/rebase-merge"
  35TODO="$DOTEST"/git-rebase-todo
  36DONE="$DOTEST"/done
  37MSG="$DOTEST"/message
  38SQUASH_MSG="$DOTEST"/message-squash
  39REWRITTEN="$DOTEST"/rewritten
  40DROPPED="$DOTEST"/dropped
  41PRESERVE_MERGES=
  42STRATEGY=
  43ONTO=
  44VERBOSE=
  45
  46GIT_CHERRY_PICK_HELP="  After resolving the conflicts,
  47mark the corrected paths with 'git add <paths>', and
  48run 'git rebase --continue'"
  49export GIT_CHERRY_PICK_HELP
  50
  51warn () {
  52        echo "$*" >&2
  53}
  54
  55output () {
  56        case "$VERBOSE" in
  57        '')
  58                output=$("$@" 2>&1 )
  59                status=$?
  60                test $status != 0 && printf "%s\n" "$output"
  61                return $status
  62                ;;
  63        *)
  64                "$@"
  65                ;;
  66        esac
  67}
  68
  69run_pre_rebase_hook () {
  70        if test -x "$GIT_DIR/hooks/pre-rebase"
  71        then
  72                "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
  73                        echo >&2 "The pre-rebase hook refused to rebase."
  74                        exit 1
  75                }
  76        fi
  77}
  78
  79require_clean_work_tree () {
  80        # test if working tree is dirty
  81        git rev-parse --verify HEAD > /dev/null &&
  82        git update-index --ignore-submodules --refresh &&
  83        git diff-files --quiet --ignore-submodules &&
  84        git diff-index --cached --quiet HEAD --ignore-submodules -- ||
  85        die "Working tree is dirty"
  86}
  87
  88ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
  89
  90comment_for_reflog () {
  91        case "$ORIG_REFLOG_ACTION" in
  92        ''|rebase*)
  93                GIT_REFLOG_ACTION="rebase -i ($1)"
  94                export GIT_REFLOG_ACTION
  95                ;;
  96        esac
  97}
  98
  99last_count=
 100mark_action_done () {
 101        sed -e 1q < "$TODO" >> "$DONE"
 102        sed -e 1d < "$TODO" >> "$TODO".new
 103        mv -f "$TODO".new "$TODO"
 104        count=$(grep -c '^[^#]' < "$DONE")
 105        total=$(($count+$(grep -c '^[^#]' < "$TODO")))
 106        if test "$last_count" != "$count"
 107        then
 108                last_count=$count
 109                printf "Rebasing (%d/%d)\r" $count $total
 110                test -z "$VERBOSE" || echo
 111        fi
 112}
 113
 114make_patch () {
 115        parent_sha1=$(git rev-parse --verify "$1"^) ||
 116                die "Cannot get patch for $1^"
 117        git diff-tree -p "$parent_sha1".."$1" > "$DOTEST"/patch
 118        test -f "$DOTEST"/message ||
 119                git cat-file commit "$1" | sed "1,/^$/d" > "$DOTEST"/message
 120        test -f "$DOTEST"/author-script ||
 121                get_author_ident_from_commit "$1" > "$DOTEST"/author-script
 122}
 123
 124die_with_patch () {
 125        make_patch "$1"
 126        git rerere
 127        die "$2"
 128}
 129
 130die_abort () {
 131        rm -rf "$DOTEST"
 132        die "$1"
 133}
 134
 135has_action () {
 136        grep '^[^#]' "$1" >/dev/null
 137}
 138
 139pick_one () {
 140        no_ff=
 141        case "$1" in -n) sha1=$2; no_ff=t ;; *) sha1=$1 ;; esac
 142        output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
 143        test -d "$REWRITTEN" &&
 144                pick_one_preserving_merges "$@" && return
 145        parent_sha1=$(git rev-parse --verify $sha1^) ||
 146                die "Could not get the parent of $sha1"
 147        current_sha1=$(git rev-parse --verify HEAD)
 148        if test "$no_ff$current_sha1" = "$parent_sha1"; then
 149                output git reset --hard $sha1
 150                test "a$1" = a-n && output git reset --soft $current_sha1
 151                sha1=$(git rev-parse --short $sha1)
 152                output warn Fast forward to $sha1
 153        else
 154                output git cherry-pick "$@"
 155        fi
 156}
 157
 158pick_one_preserving_merges () {
 159        fast_forward=t
 160        case "$1" in
 161        -n)
 162                fast_forward=f
 163                sha1=$2
 164                ;;
 165        *)
 166                sha1=$1
 167                ;;
 168        esac
 169        sha1=$(git rev-parse $sha1)
 170
 171        if test -f "$DOTEST"/current-commit
 172        then
 173                if [ "$fast_forward" == "t" ]
 174                then
 175                        cat "$DOTEST"/current-commit | while read current_commit
 176                        do
 177                                git rev-parse HEAD > "$REWRITTEN"/$current_commit
 178                        done
 179                        rm "$DOTEST"/current-commit ||
 180                        die "Cannot write current commit's replacement sha1"
 181                fi
 182        fi
 183
 184        echo $sha1 >> "$DOTEST"/current-commit
 185
 186        # rewrite parents; if none were rewritten, we can fast-forward.
 187        new_parents=
 188        pend=" $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)"
 189        while [ "$pend" != "" ]
 190        do
 191                p=$(expr "$pend" : ' \([^ ]*\)')
 192                pend="${pend# $p}"
 193
 194                if test -f "$REWRITTEN"/$p
 195                then
 196                        new_p=$(cat "$REWRITTEN"/$p)
 197                        test $p != $new_p && fast_forward=f
 198                        case "$new_parents" in
 199                        *$new_p*)
 200                                ;; # do nothing; that parent is already there
 201                        *)
 202                                new_parents="$new_parents $new_p"
 203                                ;;
 204                        esac
 205                else
 206                        if test -f "$DROPPED"/$p
 207                        then
 208                                fast_forward=f
 209                                pend=" $(cat "$DROPPED"/$p)$pend"
 210                        else
 211                                new_parents="$new_parents $p"
 212                        fi
 213                fi
 214        done
 215        case $fast_forward in
 216        t)
 217                output warn "Fast forward to $sha1"
 218                output git reset --hard $sha1 ||
 219                        die "Cannot fast forward to $sha1"
 220                ;;
 221        f)
 222                first_parent=$(expr "$new_parents" : ' \([^ ]*\)')
 223
 224                if [ "$1" != "-n" ]
 225                then
 226                        # detach HEAD to current parent
 227                        output git checkout $first_parent 2> /dev/null ||
 228                                die "Cannot move HEAD to $first_parent"
 229                fi
 230
 231                case "$new_parents" in
 232                ' '*' '*)
 233                        test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
 234
 235                        # redo merge
 236                        author_script=$(get_author_ident_from_commit $sha1)
 237                        eval "$author_script"
 238                        msg="$(git cat-file commit $sha1 | sed -e '1,/^$/d')"
 239                        # No point in merging the first parent, that's HEAD
 240                        new_parents=${new_parents# $first_parent}
 241                        if ! GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
 242                                GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
 243                                GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
 244                                output git merge $STRATEGY -m "$msg" \
 245                                        $new_parents
 246                        then
 247                                git rerere
 248                                printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
 249                                die Error redoing merge $sha1
 250                        fi
 251                        ;;
 252                *)
 253                        output git cherry-pick "$@" ||
 254                                die_with_patch $sha1 "Could not pick $sha1"
 255                        ;;
 256                esac
 257                ;;
 258        esac
 259}
 260
 261nth_string () {
 262        case "$1" in
 263        *1[0-9]|*[04-9]) echo "$1"th;;
 264        *1) echo "$1"st;;
 265        *2) echo "$1"nd;;
 266        *3) echo "$1"rd;;
 267        esac
 268}
 269
 270make_squash_message () {
 271        if test -f "$SQUASH_MSG"; then
 272                COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
 273                        < "$SQUASH_MSG" | sed -ne '$p')+1))
 274                echo "# This is a combination of $COUNT commits."
 275                sed -e 1d -e '2,/^./{
 276                        /^$/d
 277                }' <"$SQUASH_MSG"
 278        else
 279                COUNT=2
 280                echo "# This is a combination of two commits."
 281                echo "# The first commit's message is:"
 282                echo
 283                git cat-file commit HEAD | sed -e '1,/^$/d'
 284        fi
 285        echo
 286        echo "# This is the $(nth_string $COUNT) commit message:"
 287        echo
 288        git cat-file commit $1 | sed -e '1,/^$/d'
 289}
 290
 291peek_next_command () {
 292        sed -n "1s/ .*$//p" < "$TODO"
 293}
 294
 295do_next () {
 296        rm -f "$DOTEST"/message "$DOTEST"/author-script \
 297                "$DOTEST"/amend || exit
 298        read command sha1 rest < "$TODO"
 299        case "$command" in
 300        '#'*|''|noop)
 301                mark_action_done
 302                ;;
 303        pick|p)
 304                comment_for_reflog pick
 305
 306                mark_action_done
 307                pick_one $sha1 ||
 308                        die_with_patch $sha1 "Could not apply $sha1... $rest"
 309                ;;
 310        edit|e)
 311                comment_for_reflog edit
 312
 313                mark_action_done
 314                pick_one $sha1 ||
 315                        die_with_patch $sha1 "Could not apply $sha1... $rest"
 316                make_patch $sha1
 317                git rev-parse --verify HEAD > "$DOTEST"/amend
 318                warn "Stopped at $sha1... $rest"
 319                warn "You can amend the commit now, with"
 320                warn
 321                warn "  git commit --amend"
 322                warn
 323                warn "Once you are satisfied with your changes, run"
 324                warn
 325                warn "  git rebase --continue"
 326                warn
 327                exit 0
 328                ;;
 329        squash|s)
 330                comment_for_reflog squash
 331
 332                has_action "$DONE" ||
 333                        die "Cannot 'squash' without a previous commit"
 334
 335                mark_action_done
 336                make_squash_message $sha1 > "$MSG"
 337                failed=f
 338                author_script=$(get_author_ident_from_commit HEAD)
 339                output git reset --soft HEAD^
 340                pick_one -n $sha1 || failed=t
 341                case "$(peek_next_command)" in
 342                squash|s)
 343                        EDIT_COMMIT=
 344                        USE_OUTPUT=output
 345                        MSG_OPT=-F
 346                        MSG_FILE="$MSG"
 347                        cp "$MSG" "$SQUASH_MSG"
 348                        ;;
 349                *)
 350                        EDIT_COMMIT=-e
 351                        USE_OUTPUT=
 352                        MSG_OPT=
 353                        MSG_FILE=
 354                        rm -f "$SQUASH_MSG" || exit
 355                        cp "$MSG" "$GIT_DIR"/SQUASH_MSG
 356                        rm -f "$GIT_DIR"/MERGE_MSG || exit
 357                        ;;
 358                esac
 359                echo "$author_script" > "$DOTEST"/author-script
 360                if test $failed = f
 361                then
 362                        # This is like --amend, but with a different message
 363                        eval "$author_script"
 364                        GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
 365                        GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
 366                        GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
 367                        $USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t
 368                fi
 369                if test $failed = t
 370                then
 371                        cp "$MSG" "$GIT_DIR"/MERGE_MSG
 372                        warn
 373                        warn "Could not apply $sha1... $rest"
 374                        die_with_patch $sha1 ""
 375                fi
 376                ;;
 377        *)
 378                warn "Unknown command: $command $sha1 $rest"
 379                die_with_patch $sha1 "Please fix this in the file $TODO."
 380                ;;
 381        esac
 382        test -s "$TODO" && return
 383
 384        comment_for_reflog finish &&
 385        HEADNAME=$(cat "$DOTEST"/head-name) &&
 386        OLDHEAD=$(cat "$DOTEST"/head) &&
 387        SHORTONTO=$(git rev-parse --short $(cat "$DOTEST"/onto)) &&
 388        NEWHEAD=$(git rev-parse HEAD) &&
 389        case $HEADNAME in
 390        refs/*)
 391                message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" &&
 392                git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
 393                git symbolic-ref HEAD $HEADNAME
 394                ;;
 395        esac && {
 396                test ! -f "$DOTEST"/verbose ||
 397                        git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
 398        } &&
 399        rm -rf "$DOTEST" &&
 400        git gc --auto &&
 401        warn "Successfully rebased and updated $HEADNAME."
 402
 403        exit
 404}
 405
 406do_rest () {
 407        while :
 408        do
 409                do_next
 410        done
 411}
 412
 413# check if no other options are set
 414is_standalone () {
 415        test $# -eq 2 -a "$2" = '--' &&
 416        test -z "$ONTO" &&
 417        test -z "$PRESERVE_MERGES" &&
 418        test -z "$STRATEGY" &&
 419        test -z "$VERBOSE"
 420}
 421
 422get_saved_options () {
 423        test -d "$REWRITTEN" && PRESERVE_MERGES=t
 424        test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
 425        test -f "$DOTEST"/verbose && VERBOSE=t
 426}
 427
 428while test $# != 0
 429do
 430        case "$1" in
 431        --continue)
 432                is_standalone "$@" || usage
 433                get_saved_options
 434                comment_for_reflog continue
 435
 436                test -d "$DOTEST" || die "No interactive rebase running"
 437
 438                # Sanity check
 439                git rev-parse --verify HEAD >/dev/null ||
 440                        die "Cannot read HEAD"
 441                git update-index --ignore-submodules --refresh &&
 442                        git diff-files --quiet --ignore-submodules ||
 443                        die "Working tree is dirty"
 444
 445                # do we have anything to commit?
 446                if git diff-index --cached --quiet --ignore-submodules HEAD --
 447                then
 448                        : Nothing to commit -- skip this
 449                else
 450                        . "$DOTEST"/author-script ||
 451                                die "Cannot find the author identity"
 452                        amend=
 453                        if test -f "$DOTEST"/amend
 454                        then
 455                                amend=$(git rev-parse --verify HEAD)
 456                                test "$amend" = $(cat "$DOTEST"/amend) ||
 457                                die "\
 458You have uncommitted changes in your working tree. Please, commit them
 459first and then run 'git rebase --continue' again."
 460                                git reset --soft HEAD^ ||
 461                                die "Cannot rewind the HEAD"
 462                        fi
 463                        export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&
 464                        git commit --no-verify -F "$DOTEST"/message -e || {
 465                                test -n "$amend" && git reset --soft $amend
 466                                die "Could not commit staged changes."
 467                        }
 468                fi
 469
 470                require_clean_work_tree
 471                do_rest
 472                ;;
 473        --abort)
 474                is_standalone "$@" || usage
 475                get_saved_options
 476                comment_for_reflog abort
 477
 478                git rerere clear
 479                test -d "$DOTEST" || die "No interactive rebase running"
 480
 481                HEADNAME=$(cat "$DOTEST"/head-name)
 482                HEAD=$(cat "$DOTEST"/head)
 483                case $HEADNAME in
 484                refs/*)
 485                        git symbolic-ref HEAD $HEADNAME
 486                        ;;
 487                esac &&
 488                output git reset --hard $HEAD &&
 489                rm -rf "$DOTEST"
 490                exit
 491                ;;
 492        --skip)
 493                is_standalone "$@" || usage
 494                get_saved_options
 495                comment_for_reflog skip
 496
 497                git rerere clear
 498                test -d "$DOTEST" || die "No interactive rebase running"
 499
 500                output git reset --hard && do_rest
 501                ;;
 502        -s)
 503                case "$#,$1" in
 504                *,*=*)
 505                        STRATEGY="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
 506                1,*)
 507                        usage ;;
 508                *)
 509                        STRATEGY="-s $2"
 510                        shift ;;
 511                esac
 512                ;;
 513        -m)
 514                # we use merge anyway
 515                ;;
 516        -v)
 517                VERBOSE=t
 518                ;;
 519        -p)
 520                PRESERVE_MERGES=t
 521                ;;
 522        -i)
 523                # yeah, we know
 524                ;;
 525        --onto)
 526                shift
 527                ONTO=$(git rev-parse --verify "$1") ||
 528                        die "Does not point to a valid commit: $1"
 529                ;;
 530        --)
 531                shift
 532                run_pre_rebase_hook ${1+"$@"}
 533                test $# -eq 1 -o $# -eq 2 || usage
 534                test -d "$DOTEST" &&
 535                        die "Interactive rebase already started"
 536
 537                git var GIT_COMMITTER_IDENT >/dev/null ||
 538                        die "You need to set your committer info first"
 539
 540                comment_for_reflog start
 541
 542                require_clean_work_tree
 543
 544                UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
 545                test -z "$ONTO" && ONTO=$UPSTREAM
 546
 547                if test ! -z "$2"
 548                then
 549                        output git show-ref --verify --quiet "refs/heads/$2" ||
 550                                die "Invalid branchname: $2"
 551                        output git checkout "$2" ||
 552                                die "Could not checkout $2"
 553                fi
 554
 555                HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
 556                mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
 557
 558                : > "$DOTEST"/interactive || die "Could not mark as interactive"
 559                git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
 560                        echo "detached HEAD" > "$DOTEST"/head-name
 561
 562                echo $HEAD > "$DOTEST"/head
 563                echo $UPSTREAM > "$DOTEST"/upstream
 564                echo $ONTO > "$DOTEST"/onto
 565                test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
 566                test t = "$VERBOSE" && : > "$DOTEST"/verbose
 567                if test t = "$PRESERVE_MERGES"
 568                then
 569                        # $REWRITTEN contains files for each commit that is
 570                        # reachable by at least one merge base of $HEAD and
 571                        # $UPSTREAM. They are not necessarily rewritten, but
 572                        # their children might be.
 573                        # This ensures that commits on merged, but otherwise
 574                        # unrelated side branches are left alone. (Think "X"
 575                        # in the man page's example.)
 576                        mkdir "$REWRITTEN" &&
 577                        for c in $(git merge-base --all $HEAD $UPSTREAM)
 578                        do
 579                                echo $ONTO > "$REWRITTEN"/$c ||
 580                                        die "Could not init rewritten commits"
 581                        done
 582                        # No cherry-pick because our first pass is to determine
 583                        # parents to rewrite and skipping dropped commits would
 584                        # prematurely end our probe
 585                        MERGES_OPTION=
 586                else
 587                        MERGES_OPTION="--no-merges --cherry-pick"
 588                fi
 589
 590                SHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)
 591                SHORTHEAD=$(git rev-parse --short $HEAD)
 592                SHORTONTO=$(git rev-parse --short $ONTO)
 593                git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
 594                        --abbrev=7 --reverse --left-right --topo-order \
 595                        $UPSTREAM...$HEAD | \
 596                        sed -n "s/^>//p" | while read shortsha1 rest
 597                do
 598                        if test t != "$PRESERVE_MERGES"
 599                        then
 600                                echo "pick $shortsha1 $rest" >> "$TODO"
 601                        else
 602                                sha1=$(git rev-parse $shortsha1)
 603                                preserve=t
 604                                for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
 605                                do
 606                                        if test -f "$REWRITTEN"/$p
 607                                        then
 608                                                preserve=f
 609                                        fi
 610                                done
 611                                if test f = "$preserve"
 612                                then
 613                                        touch "$REWRITTEN"/$sha1
 614                                        echo "pick $shortsha1 $rest" >> "$TODO"
 615                                fi
 616                        fi
 617                done
 618
 619                # Watch for commits that been dropped by --cherry-pick
 620                if test t = "$PRESERVE_MERGES"
 621                then
 622                        mkdir "$DROPPED"
 623                        # Save all non-cherry-picked changes
 624                        git rev-list $UPSTREAM...$HEAD --left-right --cherry-pick | \
 625                                sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
 626                        # Now all commits and note which ones are missing in
 627                        # not-cherry-picks and hence being dropped
 628                        git rev-list $UPSTREAM...$HEAD --left-right | \
 629                                sed -n "s/^>//p" | while read rev
 630                        do
 631                                if test -f "$REWRITTEN"/$rev -a "$(grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
 632                                then
 633                                        # Use -f2 because if rev-list is telling us this commit is
 634                                        # not worthwhile, we don't want to track its multiple heads,
 635                                        # just the history of its first-parent for others that will
 636                                        # be rebasing on top of it
 637                                        git rev-list --parents -1 $rev | cut -d' ' -f2 > "$DROPPED"/$rev
 638                                        cat "$TODO" | grep -v "${rev:0:7}" > "${TODO}2" ; mv "${TODO}2" "$TODO"
 639                                        rm "$REWRITTEN"/$rev
 640                                fi
 641                        done
 642                fi
 643                test -s "$TODO" || echo noop >> "$TODO"
 644                cat >> "$TODO" << EOF
 645
 646# Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO
 647#
 648# Commands:
 649#  p, pick = use commit
 650#  e, edit = use commit, but stop for amending
 651#  s, squash = use commit, but meld into previous commit
 652#
 653# If you remove a line here THAT COMMIT WILL BE LOST.
 654# However, if you remove everything, the rebase will be aborted.
 655#
 656EOF
 657
 658                has_action "$TODO" ||
 659                        die_abort "Nothing to do"
 660
 661                cp "$TODO" "$TODO".backup
 662                git_editor "$TODO" ||
 663                        die "Could not execute editor"
 664
 665                has_action "$TODO" ||
 666                        die_abort "Nothing to do"
 667
 668                git update-ref ORIG_HEAD $HEAD
 669                output git checkout $ONTO && do_rest
 670                ;;
 671        esac
 672        shift
 673done