rstrip.sh: fix handling variations in "file" output
[openwrt/openwrt.git] / scripts / getver.sh
index e718485852d427300892f412dba320a494a1c23f..9175f411db8345ab420fdb1edcaf0d20f858f12f 100755 (executable)
@@ -33,14 +33,15 @@ try_git() {
                        UPSTREAM_BASE="$(git merge-base $GET_REV $ORIGIN)"
                        UPSTREAM_REV="$(git rev-list ${REBOOT}..$UPSTREAM_BASE | wc -l | awk '{print $1}')"
                else
-                       UPSTREAM_REV=$REV
+                       UPSTREAM_REV=0
                fi
 
                if [ "$REV" -gt "$UPSTREAM_REV" ]; then
                        REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
                fi
 
-               REV="${REV:+r$REV}"
+               REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
+
                ;;
        esac