Support repositories created with git worktree

* .git is a file in worktree-created copies.
* Determines the correct directory using git command, when
  running configure.
* Fixes #16808.

Change-Id: I72c7b2e79aac5140d35e0339fad16160a35911ae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6914
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
Kacper Kasper 2023-10-29 07:35:02 +01:00 committed by Adrien Destugues
parent 4391f32b36
commit 6f58244192
2 changed files with 17 additions and 7 deletions

View File

@ -377,23 +377,29 @@ actions CopySetHaikuRevision1
rule DetermineHaikuRevision
{
# If existing, make the target depend on the .git/index file in the
# root directory, so it gets updated when the revision changes due to
# commits or merges.
local gitIndex = <haiku-rootdir-git>index ;
# If existing, make the target depend on the $GIT_DIR/index file,
# so it gets updated when the revision changes due to commits or merges.
# If GIT_DIR is not set, fall back to .git/index.
local dotGit = <haiku-rootdir>.git ;
local revisionFile = <haiku-rootdir>haiku-revision ;
if ! [ on $(gitIndex) return $(HAIKU_GIT_REVISION_DETERMINED) ] {
HAIKU_GIT_REVISION_DETERMINED on $(gitIndex) = 1 ;
if ! [ on $(dotGit) return $(HAIKU_GIT_REVISION_DETERMINED) ] {
HAIKU_GIT_REVISION_DETERMINED on $(dotGit) = 1 ;
MakeLocate $(revisionFile) : $(HAIKU_BUILD_OUTPUT_DIR) ;
LocalClean clean : $(revisionFile) ;
if $(HAIKU_REVISION) {
DetermineHaikuRevision2 $(revisionFile) ;
} else if $(GIT_DIR) && $(GIT_DIR) != ".git" {
local gitIndex = <$(GIT_DIR)>index ;
SEARCH on $(gitIndex) = [ FDirName $(GIT_DIR) ] ;
Depends $(revisionFile) : $(gitIndex) ;
DetermineHaikuRevision1 $(revisionFile) : $(gitIndex) ;
} else if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] {
local gitIndex = <haiku-rootdir-git>index ;
SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ;
Depends $(revisionFile) : $(gitIndex) ;
DetermineHaikuRevision1 $(revisionFile) : $(gitIndex) ;
} else {
revisionFile = ;
Exit "ERROR: Haiku revision could not be determined." ;
}
}

4
configure vendored
View File

@ -565,6 +565,7 @@ fi
# backup the passed arguments
configureArgs="$@"
configurePath=$0
configureDir=`dirname $configurePath`
# backup relevant environs
configureEnvirons=
@ -635,6 +636,7 @@ fi
# exported (BuildSetup) default parameter values
#
GIT_DIR=`git -C "$configureDir" rev-parse --git-dir | sed 's/^gitdir: //'`
HOST_GCC_RAW_VERSION=`$CC -dumpversion`
HOST_CC_IS_LEGACY_GCC=`is_legacy_gcc $HOST_GCC_RAW_VERSION`
HOST_GCC_MACHINE=`$CC -dumpmachine`
@ -1102,6 +1104,8 @@ cat << EOF > "$buildConfigFile"
#e ${configureEnvirons}
#a ${configureArgs}
GIT_DIR ?= "${GIT_DIR}" ;
HOST_PLATFORM ?= "${HOST_PLATFORM}" ;
TARGET_PLATFORM ?= "${TARGET_PLATFORM}" ;
HAIKU_PACKAGING_ARCHS ?= ${HAIKU_PACKAGING_ARCHS} ;