[LEDE-DEV,1/4] scripts/getver.sh: fail when an invalid commit reference is given

Message ID 9fad4778d3a473af19977460c001ad7b2b9bcee4.1499645991.git.mschiffer@universe-factory.net
State New
Delegated to: Matthias Schiffer
Headers show

Commit Message

Matthias Schiffer July 10, 2017, 12:19 a.m.
Correctly return "unknown" instead of printing various error messages,
followed by a "r0-..." revision.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 scripts/getver.sh | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/scripts/getver.sh b/scripts/getver.sh
index 9175f411db..1032fa324e 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -24,6 +24,8 @@  try_git() {
 		REV="$(git rev-parse HEAD~$((BASE_REV - GET_REV)))"
 		;;
 	*)
+		git rev-parse "$GET_REV^{commit}" >/dev/null 2>&1 || return 1
+
 		BRANCH="$(git rev-parse --abbrev-ref HEAD)"
 		ORIGIN="$(git rev-parse --verify --symbolic-full-name ${BRANCH}@{u} 2>/dev/null)"
 		[ -n "$ORIGIN" ] || ORIGIN="$(git rev-parse --verify --symbolic-full-name master@{u} 2>/dev/null)"