X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=topgit.git;a=blobdiff_plain;f=tg-update.sh;h=b256c7c270b41c4e8f5d384a7ece4011d07beb74;hp=73280c65af79af2da50204582c7029a00cfcef34;hb=8d92943bcdb6eea3819dce28d2ff48dd8a061b31;hpb=e84be631e2a132b4e6ac39c0e4e2cd816eee89eb diff --git a/tg-update.sh b/tg-update.sh index 73280c6..b256c7c 100644 --- a/tg-update.sh +++ b/tg-update.sh @@ -8,13 +8,19 @@ name= ## Parse options -if [ -n "$1" ]; then - echo "Usage: tg [...] update" >&2 - exit 1 -fi - - -name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +while [ -n "$1" ]; do + arg="$1"; shift + case "$arg" in + -*) + echo "Usage: tg [...] update [NAME]" >&2 + exit 1;; + *) + [ -z "$name" ] || die "name already specified ($name)" + name="$arg";; + esac +done + +[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" || die "not a TopGit-controlled branch"