jmou/zit
git clone https://github.com/jmou/zit.git
git clone git@github.com:jmou/zit.git
Loading…
(top)/checkout
language: Shell
360 Bytes / 17 lines / 16 loc
History
View raw
#!/bin/bash -e

if [[ $1 == -b ]]; then
    branch $2
    shift
fi
revision=$1
tree=$(rev-parse $revision^{tree})
read-tree $tree
checkout-index
if [[ -f .zit/refs/heads/$revision ]]; then
    symbolic-ref HEAD refs/heads/$revision
else
    rev-parse $revision > .zit/HEAD.tmp
    mv .zit/HEAD.tmp .zit/HEAD
    echo "You are in 'detached HEAD' state." >&2
fi