diff options
author | Junio C Hamano <junkio@cox.net> | 2005-12-25 23:30:15 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-12-25 23:30:15 -0800 |
commit | 2ed7542fad01558306b6187e3b19c64243234349 (patch) | |
tree | 71d8ef2bda26cd32a0bf00f954e88105d5eec555 /git-checkout.sh | |
parent | Tutorial: mention shared repository management. (diff) | |
parent | Adjust to ls-tree --full-name when run from a subdirectory. (diff) | |
download | tgif-2ed7542fad01558306b6187e3b19c64243234349.tar.xz |
Merge branch 'jc/checkout'
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-x | git-checkout.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/git-checkout.sh b/git-checkout.sh index 36308d22c6..3bbd111773 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,6 +1,7 @@ #!/bin/sh USAGE='[-f] [-b <new_branch>] [<branch>] [<paths>...]' +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, |