From 2ea360f898a2f279ea4868a142d0db1cdd3beba3 Mon Sep 17 00:00:00 2001 From: Randolph Sapp Date: Sun, 10 Mar 2024 00:07:42 -0600 Subject: [PATCH] kp_common: fix worktree mount logic I know right now docker ignores "-v : " but I do not want to see what happens if this ever changes. Besides, we can't do anything if we're not working in a git directory anyway. Signed-off-by: Randolph Sapp --- kp_common | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kp_common b/kp_common index 5c881c3..512c2a4 100644 --- a/kp_common +++ b/kp_common @@ -47,9 +47,13 @@ DOCKER_MOUNT_DIRS+=(-v /opt:/opt) DOCKER_MOUNT_DIRS+=(-v "$CCACHEDIR":/ccache) DOCKER_MOUNT_DIRS+=(-v "$(pwd)":/workdir) +# Check if current directory is a git directory +if ! GIT_WORKTREE_COMMONDIR=$(git rev-parse --git-common-dir); then + exit 1 +fi + # Mount parent directory if its a worktree -GIT_WORKTREE_COMMONDIR=$(git rev-parse --git-common-dir) -if [[ $GIT_WORKTREE_COMMONDIR != ".git" ]]; then +if [ "$GIT_WORKTREE_COMMONDIR" != ".git" ]; then DOCKER_MOUNT_DIRS+=(-v "$GIT_WORKTREE_COMMONDIR":"$GIT_WORKTREE_COMMONDIR") fi