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