Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] utils/docker-run: fix support for git-worktrees
@ 2023-07-28 21:32 Brandon Maier via buildroot
  2023-07-29 15:33 ` Yann E. MORIN
  2023-08-30 21:59 ` [Buildroot] " Peter Korsgaard
  0 siblings, 2 replies; 6+ messages in thread
From: Brandon Maier via buildroot @ 2023-07-28 21:32 UTC (permalink / raw)
  To: buildroot; +Cc: Brandon Maier, Ricardo Martincoski

The docker-run script attempts to support git-new-workdirs and
git-worktrees by resolving the symlink at '$GIT_DIR/config' to get the
true $GIT_DIR. However this does not work for git-worktrees as they do
not use symlinks, instead they change the $GIT_DIR into a regular file
that contains the path to the real $GIT_DIR. To complicate things
further, we actually want the $GIT_COMMON_DIR which is the superset of a
worktree's $GIT_DIR.

git-rev-parse supports the '--git-common-dir' which will resolve the
$GIT_COMMON_DIR for us. However it does not work for git-new-workdirs,
so we still need to detect and handle them.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
---
 utils/docker-run | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/utils/docker-run b/utils/docker-run
index 17c587a484..db279dca68 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -2,8 +2,13 @@
 set -o errexit -o pipefail
 DIR=$(dirname "${0}")
 MAIN_DIR=$(readlink -f "${DIR}/..")
-# GIT_DIR to support workdirs/worktrees
-GIT_DIR="$(dirname "$(realpath "${MAIN_DIR}/.git/config")")"
+if [ -L "${MAIN_DIR}/.git/config" ]; then
+    # Support git-new-workdir
+    GIT_DIR="$(dirname "$(realpath "${MAIN_DIR}/.git/config")")"
+else
+    # Support git-worktree
+    GIT_DIR="$(cd "$MAIN_DIR" && readlink -f "$(git rev-parse --git-common-dir)")"
+fi
 # shellcheck disable=SC2016
 IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \
         sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-30 21:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 21:32 [Buildroot] [PATCH 1/1] utils/docker-run: fix support for git-worktrees Brandon Maier via buildroot
2023-07-29 15:33 ` Yann E. MORIN
2023-07-31 17:36   ` [Buildroot] [External] " Maier, Brandon L Collins via buildroot
2023-07-31 17:53     ` Maier, Brandon L Collins via buildroot
2023-07-31 18:50       ` Yann E. MORIN
2023-08-30 21:59 ` [Buildroot] " Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox