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 <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Kacper Kasper
2023-11-01 09:09:27 +00:00
committed by Adrien Destugues
parent 4391f32b36
commit 6f58244192
2 changed files with 17 additions and 7 deletions
+13 -7
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." ;
}
}