[PATCH] Make git-mv work in subdirectories, too
[git.git] / git-checkout.sh
index cb33fdc..4cf30e2 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-. git-sh-setup || die "Not a git archive"
+. git-sh-setup
 
 usage () {
     die "usage: git checkout [-f] [-b <new_branch>] [<branch>] [<paths>...]"
@@ -82,7 +82,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 -- "$@"
@@ -126,7 +125,9 @@ fi
 #
 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" ] &&