From e12077513fbd4ebb78dab433eaf5ec8bdaa78ba5 Mon Sep 17 00:00:00 2001
From: Angus Gratton <gus@projectgus.com>
Date: Wed, 17 Feb 2016 15:51:46 +1100
Subject: [PATCH] common.mk: Consider possibility that not building inside a
 git checkout

---
 common.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common.mk b/common.mk
index e565873..fcfaeee 100644
--- a/common.mk
+++ b/common.mk
@@ -131,7 +131,10 @@ else
     LDFLAGS += -g -O2
 endif
 
-GITSHORTREV=\"$(shell cd $(ROOT); git rev-parse --short -q HEAD)\"
+GITSHORTREV=\"$(shell cd $(ROOT); git rev-parse --short -q HEAD 2> /dev/null)\"
+ifeq ($(GITSHORTREV),\"\")
+  GITSHORTREV="\"(nogit)\"" # (same length as a short git hash)
+endif
 CPPFLAGS += -DGITSHORTREV=$(GITSHORTREV)
 
 ifeq ($(OTA),0)