summaryrefslogtreecommitdiff
path: root/git-checkout.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2005-12-25 23:30:15 -0800
committerLibravatar Junio C Hamano <junkio@cox.net>2005-12-25 23:30:15 -0800
commit2ed7542fad01558306b6187e3b19c64243234349 (patch)
tree71d8ef2bda26cd32a0bf00f954e88105d5eec555 /git-checkout.sh
parentTutorial: mention shared repository management. (diff)
parentAdjust to ls-tree --full-name when run from a subdirectory. (diff)
downloadtgif-2ed7542fad01558306b6187e3b19c64243234349.tar.xz
Merge branch 'jc/checkout'
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh11
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,