X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=git-checkout.sh;h=3bbd1117739b02572aece86030bb9f02f3110d34;hb=0f76f52621a6d760127cf2a508e09287766219b6;hp=36308d22c6a72b9ad53ced60bd3c70a2e17520b6;hpb=c2f3bf071ee90b01f2d629921bb04c4f798f02fa;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index 36308d22..3bbd1117 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,6 +1,7 @@ #!/bin/sh USAGE='[-f] [-b ] [] [...]' +SUBDIRECTORY_OK=Sometimes . git-sh-setup old=$(git-rev-parse HEAD) @@ -79,7 +80,7 @@ then # from a specific tree-ish; note that this is for # rescuing paths and is never meant to remove what # is not in the named tree-ish. - git-ls-tree -r "$new" "$@" | + git-ls-tree --full-name -r "$new" "$@" | git-update-index --index-info || exit $? fi git-checkout-index -f -u -- "$@" @@ -95,6 +96,14 @@ else fi fi +# We are switching branches and checking out trees, so +# we *NEED* to be at the toplevel. +cdup=$(git-rev-parse --show-cdup) +if test ! -z "$cdup" +then + cd "$cdup" +fi + [ -z "$new" ] && new=$old # If we don't have an old branch that we're switching to,