diff --git a/scripts/getver.sh b/scripts/getver.sh
index 340ed6862cf7cc566262ea64bfdc33196926fc4d..a60b91ede1390a5fdceccbf9d649460ccea93801 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -3,6 +3,8 @@ export LANG=C
 export LC_ALL=C
 [ -n "$TOPDIR" ] && cd $TOPDIR
 
+GET_REV=$1
+
 try_version() {
 	[ -f version ] || return 1
 	REV="$(cat version)"
@@ -11,8 +13,22 @@ try_version() {
 
 try_git() {
 	git rev-parse --git-dir >/dev/null 2>&1 || return 1
-	REV="$(git rev-list reboot..HEAD --count)"
-	REV="${REV:+r$REV}"
+
+	[ -n "$GET_REV" ] || GET_REV="HEAD"
+
+	case "$GET_REV" in
+	r*)
+		GET_REV="$(echo $GET_REV | tr -d 'r')"
+		BASE_REV="$(git rev-list reboot..HEAD --count)"
+		REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
+		;;
+	*)
+
+		REV="$(git rev-list reboot..$GET_REV --count)"
+		REV="${REV:+r$REV}"
+		;;
+	esac
+
 	[ -n "$REV" ]
 }