mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-11 16:37:45 -04:00
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
This commit is contained in:
parent
2b09078b92
commit
77f30202d0
1 changed files with 3 additions and 7 deletions
|
|
@ -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,10 +49,8 @@ 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
|
||||
echo $VERSION
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue