Skip to content

Commit

Permalink
Handle no ~/.gitconfig
Browse files Browse the repository at this point in the history
If the file doesn't exist, Docker will create a root owned empty
directory instead, which will mess any git command run on the host.
  • Loading branch information
xendk committed Nov 19, 2024
1 parent af9a16d commit a8e86e2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/dplsh/dplsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,20 @@ if [[ -z "${DPLSH_NON_INTERACTIVE:-}" ]]; then
ADDITIONAL_ARGS+=(-i)
fi

# Only mount in ${HOME}/.gitconfig if it exists. Otherwise docker will
# create an empty, root owned {HOME}/.gitconfig which will make git
# very unhappy.
if [[ -f "${HOME}/.gitconfig" ]] ; then
GITCONFIG+=(-v "${HOME}/.gitconfig:/opt/.gitconfig-host:ro")
fi

docker run --hostname=dplsh \
--rm \
"${ADDITIONAL_ARGS[@]}" \
-t \
-e "HOST_UID=$(id -u)" \
-v "${HOME}/.azure:/opt/.azure-host:ro" \
-v "${HOME}/.gitconfig:/opt/.gitconfig-host:ro" \
"${GITCONFIG[@]}" \
-v "${HOME}/.ssh:/opt/.ssh-host:ro" \
-v "${SHELL_ROOT}:/home/dplsh/host_mount" \
-w "/home/dplsh/host_mount/${CHDIR}" \
Expand Down

0 comments on commit a8e86e2

Please sign in to comment.