tools: detect Git revision correctly in non-default worktrees
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 77f30202d05bdfd051b53f8f966df1e473a0010e Author: Aidan MacDonald <[email protected]> Date: Tue Jan 27 13:23:21 2026 +0000 tools: detect Git revision correctly in non-default worktrees In a non-default Git worktree, the .git directory is replaced by a file containing the path to the real .git directory. This breaks the version detection logic because it expects .git to be a directory. Passing the root of the source tree via "git -C", letting Git figure out if we're in a repo or not, solves this problem. Change-Id: I595f1a694258cad490b1a4964f8ae9d51ae76de1 diff --git a/tools/version.sh b/tools/version.sh index 1863789917..dce5354387 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -19,16 +19,14 @@ # This logic is pulled from the Linux's scripts/setlocalversion (also GPL) # and tweaked for rockbox. gitversion() { - export GIT_DIR="$1/.git" - # This verifies we are in a git directory - if head=`git rev-parse --verify --short=10 HEAD 2>/dev/null`; then + if head=`git -C "$1" rev-parse --verify --short=10 HEAD 2>/dev/null`; then # Are there uncommitted changes? export GIT_WORK_TREE="$1" - if git diff --name-only HEAD | read dummy; then + if git -C "$1" diff --name-only HEAD | read dummy; then mod="M" - elif git diff --name-only --cached HEAD | read dummy; then + elif git -C "$1" diff --name-only --cached HEAD | read dummy; then mod="M" fi @@ -51,9 +49,7 @@ if [ -z $VERSION ]; then VER=`cat $TOP/$VERSIONFILE`; else # Ok, we need to derive it from the Version Control system - if [ -d "$TOP/.git" ]; then VER=`gitversion $TOP` - fi fi VERSION=$VER-`date -u +%y%m%d` fi -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs