+function get_ref () {
+ case "$1" in
+ refs/*)
+ echo "$1"
+ ;;
+ *)
+ echo "refs/heads/$1"
+ ;;
+ esac
+}
+
+function get_name () {
+ branch="$1"
+ rev="$2"
+ minirev=${rev:0:7}
+
+ case "$branch" in
+ refs/tags/*)
+ b="${branch#refs/tags/}"
+ echo "${b//\//-}"
+ ;;
+ refs/heads/*)
+ b=${branch#refs/heads/}
+ echo "$minirev-${b//\//-}"
+ ;;
+ refs/*)
+ b=${branch#refs/}
+ echo "$minirev-${b//\//-}"
+ ;;
+ *)
+ echo "$minirev-${branch//\//-}"
+ ;;
+ esac
+}
+