Преглед на файлове

utils/docker-run: fix running when CWD is not MAIN_DIR

Commit 90790790925c (utils/docker-run: fix support for git-worktrees)
got last-minute changes when it was applied, and the case when the
current working directory is not the top of the current working copy
got broken.

Fix that by duplicating (and thus reinstating) the 'cd MAIN_DIR' to
match what is done when retrieving the git-common-dir.

Fixes: 90790790925c

Reported-by: Brandon Maier <Brandon.Maier@collins.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Yann E. MORIN преди 2 години
родител
ревизия
5b559109ee
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      utils/docker-run

+ 4 - 3
utils/docker-run

@@ -27,9 +27,10 @@ declare -a docker_opts=(
 # .git directory.
 # .git directory.
 if [ "${GIT_DIR}" ]; then
 if [ "${GIT_DIR}" ]; then
     # GIT_DIR in the main working copy (when git supports worktrees) will
     # GIT_DIR in the main working copy (when git supports worktrees) will
-    # be just '.git', but 'docker run' needs an absolute path. If it's an
-    # absolute path already (in a wordir), then that's a noop.
-    GIT_DIR="$(readlink -e "${GIT_DIR}")"
+    # be just '.git', but 'docker run' needs an absolute path. If it is
+    # 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}" )
     docker_opts+=( --mount "type=bind,src=${GIT_DIR},dst=${GIT_DIR}" )
 fi
 fi