|
@@ -17,10 +17,11 @@ declare -a docker_opts=(
|
|
|
-i
|
|
|
--rm
|
|
|
--user "$(id -u):$(id -g)"
|
|
|
- --mount "type=bind,src=${MAIN_DIR},dst=${MAIN_DIR}"
|
|
|
--workdir "${MAIN_DIR}"
|
|
|
)
|
|
|
|
|
|
+declare -a mountpoints=( "${MAIN_DIR}" )
|
|
|
+
|
|
|
# Empty GIT_DIR means that we are not in a workdir, *and* git is too old
|
|
|
# to know about worktrees, so we're not in a worktree either. So it means
|
|
|
# we're in the main git working copy, and thus we don't need to mount the
|
|
@@ -31,9 +32,14 @@ if [ "${GIT_DIR}" ]; then
|
|
|
# not absolute, GIT_DIR is relative to MAIN_DIR. If it's an absolute
|
|
|
# path already (in a wordir), then that's a noop.
|
|
|
GIT_DIR="$(cd "${MAIN_DIR}"; readlink -e "${GIT_DIR}")"
|
|
|
- docker_opts+=( --mount "type=bind,src=${GIT_DIR},dst=${GIT_DIR}" )
|
|
|
+ mountpoints+=( "${GIT_DIR}" )
|
|
|
fi
|
|
|
|
|
|
+# shellcheck disable=SC2013 # can't use while-read because of the assignment
|
|
|
+for dir in $(printf '%s\n' "${mountpoints[@]}" |LC_ALL=C sort -u); do
|
|
|
+ docker_opts+=( --mount "type=bind,src=${dir},dst=${dir}" )
|
|
|
+done
|
|
|
+
|
|
|
if tty -s; then
|
|
|
docker_opts+=( -t )
|
|
|
fi
|