From 1e2498bbe41f3d55e04a31fc68b2ade3aabde1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 30 Oct 2018 18:48:47 +0100 Subject: [PATCH] makefiles/docker.inc.mk: handle building in git worktree When building from a worktree, the common git directory was not mounted in docker. This lead to the version not being set and issues with git-cache in ubuntu bionic that could not execute the 'git hash-object' command. (cherry picked from commit 61a3e5d68555ac48723f4039ea19bf6bd1c2666c) --- makefiles/docker.inc.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index 1fd8766a0968..3c6cb9202978 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -89,6 +89,11 @@ DOCKER ?= docker DOCKER_VOLUMES_AND_ENV += $(if $(wildcard $(GIT_CACHE_DIR)),-v $(GIT_CACHE_DIR):$(DOCKER_BUILD_ROOT)/gitcache) DOCKER_VOLUMES_AND_ENV += $(if $(wildcard $(GIT_CACHE_DIR)),-e GIT_CACHE_DIR=$(DOCKER_BUILD_ROOT)/gitcache) +# Handle worktree by mounting the git common dir in the same location +_is_git_worktree = $(shell grep '^gitdir: ' $(RIOTBASE)/.git 2>/dev/null) +GIT_WORKTREE_COMMONDIR = $(shell git rev-parse --git-common-dir) +DOCKER_VOLUMES_AND_ENV += $(if $(_is_git_worktree),-v $(GIT_WORKTREE_COMMONDIR):$(GIT_WORKTREE_COMMONDIR)) + # This will execute `make $(DOCKER_MAKECMDGOALS)` inside a Docker container. # We do not push the regular $(MAKECMDGOALS) to the container's make command in # order to only perform building inside the container and defer executing any