jmou/zit
git clone https://github.com/jmou/zit.git
git clone git@github.com:jmou/zit.git
Loading…
(top)/symbolic-ref
language: Shell
297 Bytes / 13 lines / 12 loc
History
View raw
#!/bin/bash -e

if [[ $# == 2 ]]; then
    # refs.c:create_symref
    echo "ref: $2" > .zit/$1
elif [[ $# == 1 ]]; then
    # refs.c:resolve_ref
    path=.zit/$1
    while grep -q '^ref: ' $path 2> /dev/null; do
        path=.zit/$(cut -d' ' -f2 < $path)
    done
    echo $path | cut -d/ -f2-
fi