X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-checkout.sh;h=36308d22c6a72b9ad53ced60bd3c70a2e17520b6;hb=1e80e0449248edb77b0fb9853f4a3404a599e207;hp=cb33fdc7e20272a77d97d1b68c31d9b93d3cf4d4;hpb=b0bafe0364860ba45b74a5aec5b920213d5caa34;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index cb33fdc7..36308d22 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,9 +1,7 @@ #!/bin/sh -. git-sh-setup || die "Not a git archive" -usage () { - die "usage: git checkout [-f] [-b ] [] [...]" -} +USAGE='[-f] [-b ] [] [...]' +. git-sh-setup old=$(git-rev-parse HEAD) new= @@ -82,7 +80,6 @@ then # rescuing paths and is never meant to remove what # is not in the named tree-ish. git-ls-tree -r "$new" "$@" | - sed -ne 's/^\([0-7]*\) blob \(.*\)$/\1 \2/p' | git-update-index --index-info || exit $? fi git-checkout-index -f -u -- "$@" @@ -119,14 +116,16 @@ else fi # -# Switch the HEAD pointer to the new branch if it we +# Switch the HEAD pointer to the new branch if we # checked out a branch head, and remove any potential # old MERGE_HEAD's (subsequent commits will clearly not # be based on them, since we re-set the index) # if [ "$?" -eq 0 ]; then if [ "$newbranch" ]; then - echo $new > "$GIT_DIR/refs/heads/$newbranch" + leading=`expr "refs/heads/$newbranch" : '\(.*\)/'` && + mkdir -p "$GIT_DIR/$leading" && + echo $new >"$GIT_DIR/refs/heads/$newbranch" || exit branch="$newbranch" fi [ "$branch" ] &&