projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add --keep option to keep downloaded packs to git-fetch.
[git.git]
/
git-checkout.sh
diff --git
a/git-checkout.sh
b/git-checkout.sh
index
36308d2
..
3bbd111
100755
(executable)
--- a/
git-checkout.sh
+++ b/
git-checkout.sh
@@
-1,6
+1,7
@@
#!/bin/sh
USAGE='[-f] [-b <new_branch>] [<branch>] [<paths>...]'
#!/bin/sh
USAGE='[-f] [-b <new_branch>] [<branch>] [<paths>...]'
+SUBDIRECTORY_OK=Sometimes
. git-sh-setup
old=$(git-rev-parse HEAD)
. 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.
# 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 -- "$@"
git-update-index --index-info || exit $?
fi
git-checkout-index -f -u -- "$@"
@@
-95,6
+96,14
@@
else
fi
fi
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,
[ -z "$new" ] && new=$old
# If we don't have an old branch that we're switching to,