1
0
mirror of https://github.com/git/git.git synced 2024-09-29 19:01:25 +02:00
git/git-checkout-script
Linus Torvalds a79944d76c "git checkout": add "-u" flag to update HEAD conditionally
And fix braino on testing "-f".
2005-06-21 09:59:26 -07:00

34 lines
531 B
Bash
Executable File

#!/bin/sh
: ${GIT_DIR=.git}
old=$(git-rev-parse HEAD)
new=$(git-rev-parse --revs-only "$@")
new=${new:-$old}
args=($(git-rev-parse --no-revs "$@"))
i=0
force=
update=
while [ $i -lt ${#args} ]; do
case "${args[$i]}" in
"-f")
force=1;;
"-u")
update=1;;
"")
;;
*)
echo "unknown flag ${args[$i]}"
exit 1;;
esac
i=$(($i+1))
done
if [ "$force" ]
then
git-read-tree --reset $new &&
git-checkout-cache -q -f -u -a
else
git-read-tree -m -u $old $new
fi && [ "$update" ] && echo $new > "$GIT_DIR/HEAD"