diff options
Diffstat (limited to 'git-checkout-script')
-rwxr-xr-x | git-checkout-script | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/git-checkout-script b/git-checkout-script new file mode 100755 index 0000000000..e8e777f1f2 --- /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 |