util/genbuild_h: improve robustness against corrupt .git directories

The new test lets git check if $top is actually a git repo, instead of
just looking for clues.

BUG=chromium:776174
BRANCH=none
TEST=`mv .git .foo; mkdir .git; util/genbuild_h/genbuild_h.sh` provides
a valid build.h instead of failing because git is unhappy about the
.git directory.

Change-Id: I7fcc64d66e0b59fca1479b4c142fd0559aa984f4
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/22107
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Patrick Georgi 2017-10-19 03:45:25 -04:00
parent fe84292eeb
commit 44aaf6137d
1 changed files with 1 additions and 1 deletions

View File

@ -28,7 +28,7 @@ if [ "${BUILD_TIMELESS}" = "1" ]; then
GITREV=Timeless
TIMESOURCE="fixed"
DATE=0
elif [ -e "${top}/.git" -a -x "$(command -v git)" ]; then
elif GIT_DIR="${top}/.git" git status > /dev/null 2>&1; then
GITREV=$(LANG= git log -1 --format=format:%h)
TIMESOURCE=git
DATE=$(git log --pretty=format:%ct -1)