4 [ -n "$TOPDIR" ] && cd $TOPDIR
9 [ -f version ] || return 1
15 git rev-parse --git-dir >/dev/null 2>&1 || return 1
17 [ -n "$GET_REV" ] || GET_REV="HEAD"
21 GET_REV="$(echo $GET_REV | tr -d 'r')"
22 BASE_REV="$(git rev-list reboot..HEAD | wc -l)"
23 REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
26 BRANCH="$(git rev-parse --abbrev-ref HEAD)"
27 ORIGIN="$(git rev-parse --symbolic-full-name ${BRANCH}@{u} 2>/dev/null)"
28 [ -n "$ORIGIN" ] || ORIGIN="$(git rev-parse --symbolic-full-name master@{u} 2>/dev/null)"
29 REV="$(git rev-list reboot..$GET_REV | wc -l | awk '{print $1}')"
31 if [ -n "$ORIGIN" ]; then
32 UPSTREAM_BASE="$(git merge-base $GET_REV $ORIGIN)"
33 UPSTREAM_REV="$(git rev-list reboot..$UPSTREAM_BASE | wc -l | awk '{print $1}')"
38 if [ "$REV" -gt "$UPSTREAM_REV" ]; then
39 REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
50 [ -d .hg ] || return 1
51 REV="$(hg log -r-1 --template '{desc}' | awk '{print $2}' | sed 's/\].*//')"
56 try_version || try_git || try_hg || REV="unknown"