summaryrefslogtreecommitdiff
path: root/git-checkout-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 16:47:37 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 16:47:37 (GMT)
commit303e5f4c325d008c68e5e70e901ab68b289ade2e (patch)
treea0f2f1d6795edac667b70bccc420f2a8b9c9c93a /git-checkout-script
parent83ba99bc8c2cdbaa9a0b4ec286e72c3ecb31bf8a (diff)
downloadgit-303e5f4c325d008c68e5e70e901ab68b289ade2e.zip
git-303e5f4c325d008c68e5e70e901ab68b289ade2e.tar.gz
git-303e5f4c325d008c68e5e70e901ab68b289ade2e.tar.bz2
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.
Diffstat (limited to 'git-checkout-script')
-rwxr-xr-xgit-checkout-script30
1 files changed, 30 insertions, 0 deletions
diff --git a/git-checkout-script b/git-checkout-script
new file mode 100755
index 0000000..e8e777f
--- /dev/null
+++ b/git-checkout-script
@@ -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