Add "git checkout" that does what the name suggests

It is careful by default and refuses to overwrite old info, but if you
want to force everything to be re-read, use the "-f" flag.

Some day I'll make it take individual filenames too. Right now
it's all-or-nothing.
This commit is contained in:
Linus Torvalds
2005-06-21 09:47:37 -07:00
parent 83ba99bc8c
commit 303e5f4c32
2 changed files with 31 additions and 1 deletions

30
git-checkout-script Executable file
View File

@ -0,0 +1,30 @@
#!/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=0
while [ $i -lt ${#args} ]; do
case "${args[$i]}" in
"-f")
force=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 &&
echo $new > "$GIT_DIR/HEAD"
else
git-read-tree -m -u $old $new && echo $new > "$GIT_DIR/HEAD"
fi