From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Brandon Maier <brandon.maier@collins.com>
Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br>,
buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] utils/docker-run: fix support for git-worktrees
Date: Sat, 29 Jul 2023 17:33:10 +0200 [thread overview]
Message-ID: <20230729153310.GA229077@scaer> (raw)
In-Reply-To: <20230728213218.3893857-1-brandon.maier@collins.com>
Brandon, All,
On 2023-07-28 21:32 +0000, Brandon Maier via buildroot spake thusly:
> 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>
Thanks, I've pushed it to master with a few changes:
- support git versions before --git-common-dir was introduced
- don't mount GIT_DIR if unknown (i.e. not needed)
- fix expanding MAIN_DIR
See below..
> ---
> 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)")"
^^^^^^^^^
Expansion should use curly braces, like everywhere else.
--git-common-dir was only introduced in git 2.10.0, which is most
probably not available in enterprise-grade distros like RHEL (RHEL 7 is
still maintained, and it is based on Fedora 19; there's only a docker
image for Fedora 20, and that has git 1.9).
So I've added --no-flags, that has been present since at least 1.0.0,
which means that, on git versions that did not support worktrees, we'll
get an empty GIT_DIR, so that's OK: it means we're in the main working
copy, and thus we don't need the mount.
Applied to master with those changes, thanks.
Regards,
Yann E. MORIN.
> +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
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2023-07-29 15:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230729153310.GA229077@scaer \
--to=yann.morin.1998@free.fr \
--cc=brandon.maier@collins.com \
--cc=buildroot@buildroot.org \
--cc=ricardo.martincoski@datacom.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox