From: Jörg Sommer <
joerg....@navimatix.de>
Git support sharing the .git directory across multiple worktrees each having
its own HEAD, index, rebase-todo and so on. The worktree directory (created
with `git worktree`) contains no directory .git, but a file .git with a
reference to the main git directory. Therefore, this directory must also be
mounted in the container to make git operable.
Closes: #107
Signed-off-by: Jörg Sommer <
joerg....@navimatix.de>
---
kas-container | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kas-container b/kas-container
index 6b2131c3..2c6505f6 100755
--- a/kas-container
+++ b/kas-container
@@ -452,6 +452,13 @@ if [ "$(id -u)" -eq 0 ] && [ "${KAS_ALLOW_ROOT}" != "yes" ] ; then
"KAS_ALLOW_ROOT=yes to override."
fi
+if git_com_dir=$(git -C "${KAS_REPO_DIR}" rev-parse --git-common-dir 2>/dev/null) \
+ && [ "$git_com_dir" != "$(git -C "${KAS_REPO_DIR}" rev-parse --git-dir 2>/dev/null)" ]; then
+ # if (it's a git repo) and the common dir isn't the git-dir, it is shared worktree and
+ # we have to mount the common dir in the container to make git work
+ set -- "$@" -v "$git_com_dir:$git_com_dir:${KAS_REPO_MOUNT_OPT}"
+fi
+
set -- "$@" -v "${KAS_REPO_DIR}:/repo:${KAS_REPO_MOUNT_OPT}" \
-v "${KAS_WORK_DIR}":/work:rw -e KAS_WORK_DIR=/work \
-v "${KAS_BUILD_DIR}":/build:rw \
--
2.45.2