Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [RFC] Support git worktree
Date: Wed, 22 Apr 2020 02:49:27 +0200	[thread overview]
Message-ID: <20200422004927.V_NN8EjDPUXPziuphCgoU735iJUzwaEraIvYhGK50t8@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-21207@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 613 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages support-git-worktree
https://github.com/void-linux/void-packages/pull/21207

[RFC] Support git worktree
My effort to address #20393 

There's still 1 more issue.

This PR haven't set `XBPS_REPOSITORY` to correct branch yet.

Because I'm not sure if this direction is favourable, and it's very late in my timezone.

The second patch should be fixed-up into the first patch if it's desired.

A patch file from https://github.com/void-linux/void-packages/pull/21207.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-support-git-worktree-21207.patch --]
[-- Type: text/x-diff, Size: 9753 bytes --]

From b305b4e73076b094cb960dad6584d6dc0bed4ecd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Mon, 20 Apr 2020 23:18:14 +0700
Subject: [PATCH 1/5] setup/git.sh: prefer git plumbing command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

git-ls-files(1) is plumbing command, its output will never change
regardless of configuration, version.

git-status(1) output will be changed depends on configuration.
At least, 986d4dbc7d (common/environment/setup/git.sh: ensure untracked
files are checked., 2017-11-24) was added to address a different output
on `status.showUntrackedFiles`.

By doing this, also reduce a pipe, and a fork-exec.

Technically, git-log(1) is also a porcelain, but I _think_ `%ct` is
stable enough to stay there. If the day has come, that `git-log(1)` can
be replaced with:

    git cat-file commit HEAD |
    sed -ne '/^committer/{s/.* \([0-9]\+\) [-+][0-9][0-9][0-9][0-9]$/\1/p;q}'
---
 common/environment/setup/git.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..253a423fe6c 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -11,7 +11,7 @@ if [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 		GIT_CMD=$(command -v git)
 	fi
 	# check if the template is under version control:
-	if $GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
 		export SOURCE_DATE_EPOCH="$(stat -c %Y ${XBPS_SRCPKGDIR}/${basepkg}/template)"
 	else
 		export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From c6065b875f92335f13a9f2bacb7cc64db1b90cc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Tue, 21 Apr 2020 00:02:29 +0700
Subject: [PATCH 2/5] fixup??! setup/git.sh: prefer git plumbing command

Technically, git-log(1) is also a porcelain, but I _think_ `%ct` is
stable enough to stay there.

If we chose to switch to all plumbing command, squash this change to
previous change and update the commit message there.

If we prefer to use git-log(1) instead, just drop this one.
---
 common/environment/setup/git.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 253a423fe6c..f9b0c058c4a 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -14,6 +14,7 @@ if [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	if [ -z "$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
 		export SOURCE_DATE_EPOCH="$(stat -c %Y ${XBPS_SRCPKGDIR}/${basepkg}/template)"
 	else
-		export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
+		export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |
+			sed -ne '/^committer/{s/.* \([0-9]\+\) [-+][0-9][0-9][0-9][0-9]$/\1/p;q}')"
 	fi
 fi

From 1768804aef7a8b6f2617aa7a12846ea4ea491cff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Tue, 21 Apr 2020 00:14:49 +0700
Subject: [PATCH 3/5] setup: export SOURCE_DATE_EPOCH from outside of chroot

git-worktree(1), and Git shared repository can use a plain text file
named `.git` at the root of working tree, containing `gitdir: <path>` to
point to the real directory that has repository.
See: gitrepository-layout(5).

But, that directory is usually inaccessible inside chroot.

In order to support git-worktree(1) and Git shared repository, compute
SOURCE_DATE_EPOCH from outside of chroot, and the chroot will carry it
over to inside chroot.

I've only tested again xbps-uunshare(1).
---
 common/environment/setup/git.sh | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index f9b0c058c4a..8fbce005614 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -2,19 +2,16 @@
 # only run this, if SOURCE_DATE_EPOCH isn't set.
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-	return 0
-fi
-if [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
-	if command -v chroot-git &>/dev/null; then
-		GIT_CMD=$(command -v chroot-git)
-	elif command -v git &>/dev/null; then
-		GIT_CMD=$(command -v git)
-	fi
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	elif ! command -v git &>/dev/null; then
+		msg_error "command not found: git\n"
 	# check if the template is under version control:
-	if [ -z "$($GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	elif [ -n "$basepkg" -a -z "$(git -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
 		export SOURCE_DATE_EPOCH="$(stat -c %Y ${XBPS_SRCPKGDIR}/${basepkg}/template)"
 	else
-		export SOURCE_DATE_EPOCH="$($GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |
+		export SOURCE_DATE_EPOCH="$(git -C ${XBPS_DISTDIR} cat-file commit HEAD |
 			sed -ne '/^committer/{s/.* \([0-9]\+\) [-+][0-9][0-9][0-9][0-9]$/\1/p;q}')"
 	fi
 fi

From 3baaa53bf76be97d4ccb4d4b2d801d19e73ef298 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Tue, 21 Apr 2020 22:52:38 +0700
Subject: [PATCH 4/5] setup: compute gitrev from outside of chroot

Together with previous commit, `xbps-src` is able to support
git-worktree and shared repository by now.
---
 common/environment/setup/git.sh                  | 14 ++++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 14 ++++----------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 8fbce005614..d31bcf0a21e 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -15,3 +15,17 @@ elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
 			sed -ne '/^committer/{s/.* \([0-9]\+\) [-+][0-9][0-9][0-9][0-9]$/\1/p;q}')"
 	fi
 fi
+
+# if XBPS_USE_GIT_REVS is enabled in conf file,
+# compute XBPS_GIT_REVS to use in pkg hooks
+if [ -z "$XBPS_USE_GIT_REVS" ]; then
+	unset XBPS_GIT_REVS
+elif [ -z "$XBPS_GIT_REVS" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: XBPS_GIT_REVS is undefined\n"
+	elif ! command -v git &>/dev/null; then
+		msg_error "command not found: git\n"
+	else
+		export XBPS_GIT_REVS="$(git -C "${XBPS_DISTDIR}" rev-parse --verify --short HEAD)"
+	fi
+fi
diff --git a/common/hooks/post-install/05-generate-gitrevs.sh b/common/hooks/post-install/05-generate-gitrevs.sh
index 82b2ab1a786..29485a6ad6d 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,6 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +13,11 @@ hook() {
 		return
 	fi
 
-	if command -v chroot-git &>/dev/null; then
-		GIT_CMD=$(command -v chroot-git)
-	elif command -v git &>/dev/null; then
-		GIT_CMD=$(command -v git)
-	else
-		msg_error "$pkgver: cannot find chroot-git or git utility, exiting...\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "xbps-src's BUG: XBPS_GIT_REVS should be defined.\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
-	echo "${sourcepkg}:${rev}"
-	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
+	echo "${sourcepkg}:${XBPS_GIT_REVS}"
+	echo "${sourcepkg}:${XBPS_GIT_REVS}" > $GITREVS_FILE
 }
diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 1298952fd40..436f8866cd4 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -175,6 +175,7 @@ chroot_handler() {
             ${HTTP_PROXY_AUTH:+HTTP_PROXY_AUTH="${HTTP_PROXY_AUTH}"} \
             ${FTP_RETRIES:+FTP_RETRIES="${FTP_RETRIES}"} \
             SOURCE_DATE_EPOCH="$SOURCE_DATE_EPOCH" \
+            XBPS_GIT_REVS="$XBPS_GIT_REVS" \
             XBPS_ALLOW_CHROOT_BREAKOUT="$XBPS_ALLOW_CHROOT_BREAKOUT" \
             $XBPS_COMMONDIR/chroot-style/${XBPS_CHROOT_CMD:=uunshare}.sh \
             $XBPS_MASTERDIR $XBPS_DISTDIR "$XBPS_HOSTDIR" "$XBPS_CHROOT_CMD_ARGS" \

From 4d793eb57436c5d91bea88e6e4218bd5e0c0ced2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx+sgn@gmail.com>
Date: Wed, 22 Apr 2020 07:49:14 +0700
Subject: [PATCH 5/5] chroot-git: update to 2.26.2.

---
 srcpkgs/chroot-git/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index e685ed7dfa1..8ff8d7e7502 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -1,6 +1,6 @@
 # Template file for 'chroot-git'
 pkgname=chroot-git
-version=2.26.0
+version=2.26.2
 revision=1
 bootstrap=yes
 wrksrc="git-${version}"
@@ -14,7 +14,7 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://git-scm.com/"
 distfiles="https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz"
-checksum=9ece0dcb07a5e0d7366a92b613b201cca11ae368ab7687041364b3e756e495d6
+checksum=888228408f254634330234df3cece734d190ef6381063821f31ec020538f0368
 
 if [ "$CHROOT_READY" ]; then
 	hostmakedepends="perl gettext tar"

  parent reply	other threads:[~2020-04-22  0:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 16:25 [PR PATCH] " sgn
2020-04-21 16:43 ` xtraeme
2020-04-22  0:01 ` sgn
2020-04-22  0:44 ` sgn
2020-04-22  0:49 ` sgn [this message]
2020-04-22  0:51 ` sgn
2020-04-22  0:51 ` sgn
2020-04-22 15:07 ` [PR PATCH] [Updated] " sgn
2020-04-22 16:00 ` sgn
2020-04-22 16:14 ` sgn
2020-04-22 16:15 ` sgn
2020-04-22 16:28 ` sgn
2020-04-22 16:30 ` sgn
2020-04-22 16:41 ` Piraty
2020-04-26  1:19 ` [PR PATCH] [Updated] " sgn
2020-04-26  1:20 ` sgn
2020-04-26  7:53 ` Piraty
2020-05-18 11:49 ` [PR PATCH] [Updated] " sgn
2020-05-19 12:26 ` sgn
2020-05-19 13:19 ` sgn
2020-05-23  6:59 ` [PR PATCH] [Merged]: " sgn
2020-05-23 12:25 ` Piraty

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=20200422004927.V_NN8EjDPUXPziuphCgoU735iJUzwaEraIvYhGK50t8@z \
    --to=sgn@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /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;
as well as URLs for NNTP newsgroup(s).