diff mbox

[OpenWrt-Devel] scripts: fix getver git dir check

Message ID 8baf4e3d48945b69b377c24cb199b0a48f3c3a4d.1423941797.git.heffer@fedoraproject.org
State Accepted
Headers show

Commit Message

Felix Kaechele Feb. 14, 2015, 7:24 p.m. UTC
Git internals are referenced by .git which isn't necessarily a
directory. It may also be a file that references the actual .git
directory using the gitdir directive.

If .git is assumed to be a directory the build will not be able to get
the correct version when openwrt is included as a git submodule because
when used as a submodule .git will actually be a file referencing to a
subdirectory in the parent's git dir.

When the correct version is not detected some image generation tools
will fail because the OpenWrt string will be 'OpenWrtunknown' which is
too long for some header formats.

Signed-off-by: Felix Kaechele <heffer@fedoraproject.org>
---
 scripts/getver.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/scripts/getver.sh b/scripts/getver.sh
index 8bb384b..4643ca6 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -17,7 +17,7 @@  try_svn() {
 }
 
 try_git() {
-	[ -d .git ] || return 1
+	[ -e .git ] || return 1
 	REV="$(git log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "", $0); print $1 }')"
 	REV="${REV:+r$REV}"
 	[ -n "$REV" ]