X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-checkout.sh;h=4cf30e2c0529e90886e6edfd485cec67a278e224;hb=2c4ed386e8861e730037abe4f4d9e032c5c46242;hp=73652fa5f367b8200a9fb05740c09cf12a72bc54;hpb=1301c6eb412e7c5511b952a12e42c70ad56f028b;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index 73652fa5..4cf30e2c 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,5 +1,9 @@ #!/bin/sh -. git-sh-setup || die "Not a git archive" +. git-sh-setup + +usage () { + die "usage: git checkout [-f] [-b ] [] [...]" +} old=$(git-rev-parse HEAD) new= @@ -26,6 +30,9 @@ while [ "$#" != "0" ]; do --) break ;; + -*) + usage + ;; *) if rev=$(git-rev-parse --verify "$arg^0" 2>/dev/null) then @@ -75,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 -- "$@" @@ -119,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" ] &&