summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-checkout.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index 36308d2..1219ea0 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)
@@ -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,