Github messages for voidlinux
 help / color / Atom feed
* [PR PATCH] [RFC] Support git worktree
@ 2020-04-21 16:25 sgn
  2020-04-21 16:43 ` xtraeme
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: sgn @ 2020-04-21 16:25 UTC (permalink / raw)
  To: ml


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

There is a new 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: 8635 bytes --]

From 90d81277864ce74f0e2340b0c24d6e61de605a96 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/4] 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 8a195001732443eb859dd1db6be91ff8c632e2f9 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/4] 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 5db66db4498289aa84b4bfad019034f7006d7f9d 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/4] 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..7372de1fed0 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 [ -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 c1c995094da67c7fb6a0130d74386eed7e8865b0 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/4] 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 7372de1fed0..dffd69ec00d 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" \

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
@ 2020-04-21 16:43 ` xtraeme
  2020-04-22  0:01 ` sgn
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: xtraeme @ 2020-04-21 16:43 UTC (permalink / raw)
  To: ml


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

New comment by xtraeme on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617270156

Comment:
I like the idea, this will allow us to get rid of chroot-git as well.



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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
  2020-04-21 16:43 ` xtraeme
@ 2020-04-22  0:01 ` sgn
  2020-04-22  0:44 ` sgn
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22  0:01 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617471997

Comment:
On 2020-04-21 09:34:46-0700, Juan RP <notifications@github.com> wrote:
> I like the idea, this will allow us to get rid of chroot-git as well.

I thought about get rid of `chroot-git` as well.
But even if split single `/usr/bin/git` out of git (to provide e.g.
git-core), it still have dependencies on libpcre2.

Not sure if the added dependencies to base-chroot annoys anyone.


-- 
Danh


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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
  2020-04-21 16:43 ` xtraeme
  2020-04-22  0:01 ` sgn
@ 2020-04-22  0:44 ` sgn
  2020-04-22  0:49 ` [PR PATCH] [Updated] " sgn
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22  0:44 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617483099

Comment:
The change is _NOT_ ready yet.
`xbump` tool report an error.


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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (2 preceding siblings ...)
  2020-04-22  0:44 ` sgn
@ 2020-04-22  0:49 ` sgn
  2020-04-22  0:51 ` sgn
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22  0:49 UTC (permalink / raw)
  To: ml


[-- 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"

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (3 preceding siblings ...)
  2020-04-22  0:49 ` [PR PATCH] [Updated] " sgn
@ 2020-04-22  0:51 ` sgn
  2020-04-22  0:51 ` sgn
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22  0:51 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617483099

Comment:
~The change is _NOT_ ready yet.~
~`xbump` tool report an error.~

Fixed by checking for empty `basepkg`


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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (4 preceding siblings ...)
  2020-04-22  0:51 ` sgn
@ 2020-04-22  0:51 ` sgn
  2020-04-22 15:07 ` [PR PATCH] [Updated] " sgn
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22  0:51 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617483099

Comment:
~The change is _NOT_ ready yet.~
~`xbump` tool report an error.~

Fixed by checking for empty `basepkg`.

Updated `chroot-git` to check with Travis


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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (5 preceding siblings ...)
  2020-04-22  0:51 ` sgn
@ 2020-04-22 15:07 ` sgn
  2020-04-22 16:00 ` sgn
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 15:07 UTC (permalink / raw)
  To: ml


[-- 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: 12687 bytes --]

From f18a85c7965d6d18a9088a30778481eb5d43fd17 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 20:59:26 +0700
Subject: [PATCH 1/6] xbps-src: use $XBPS_GIT_CMD for git

---
 common/environment/setup/git.sh                | 18 ++++++++----------
 .../hooks/post-install/05-generate-gitrevs.sh  | 12 ++++--------
 xbps-src                                       |  5 ++---
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..a2f7f0a28ee 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -1,19 +1,17 @@
 # If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
 # only run this, if SOURCE_DATE_EPOCH isn't set.
+
+if [ -z "$XBPS_GIT_CMD" ]; then
+	msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
+fi
+
 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}" -a -n "$IN_CHROOT" ]; then
 	# 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 $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; 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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 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..754ba8865b9 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,7 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
+	local rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +14,12 @@ 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_CMD" ]; then
+		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
+	rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
 	echo "${sourcepkg}:${rev}"
 	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
 }
diff --git a/xbps-src b/xbps-src
index 459f27eb7b7..34c51bb182e 100755
--- a/xbps-src
+++ b/xbps-src
@@ -500,14 +500,13 @@ fi
 
 # Try using chroot-git then git from the host system
 if command -v chroot-git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v chroot-git)
+    export XBPS_GIT_CMD=$(command -v chroot-git)
 elif command -v git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v git)
+    export XBPS_GIT_CMD=$(command -v git)
 else
     echo "neither chroot-git or git are available in your system!" 1>&2
     exit 1
 fi
-readonly XBPS_GIT_CMD
 
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs

From d5ae22ea037dd035e0a954110edc5fd80d4277e4 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 2/6] 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 a2f7f0a28ee..a7395ef53f3 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -9,7 +9,7 @@ if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
 elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	# check if the template is under version control:
-	if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 54bfb0bf7d81218fe8a3240acee2d35a154aa3d0 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 3/6] 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 a7395ef53f3..25cddf68e91 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -12,6 +12,7 @@ elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
+		export SOURCE_DATE_EPOCH="$($XBPS_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 458850fed073358d6d49c296ee92f7a26755e3b1 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 4/6] 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 25cddf68e91..8a45c5dd28b 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -7,9 +7,12 @@ fi
 
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	fi
 	# check if the template is under version control:
-	if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	if [ -n "$basepkg" -a -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |

From aa7875a7dce477b4e81d323fe147b0255424eccf 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 5/6] 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                  | 12 ++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 10 ++++------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 8a45c5dd28b..8372461247e 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -19,3 +19,15 @@ 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"
+	else
+		export XBPS_GIT_REVS="$($XBPS_GIT_CMD -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 754ba8865b9..c5a51f0d101 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 rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,12 +13,11 @@ hook() {
 		return
 	fi
 
-	if [ -z "$XBPS_GIT_CMD" ]; then
-		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "BUG: XBPS_GIT_REVS is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($XBPS_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 7dada769f45452b038800dc47a8f7f1dd1be0df8 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 6/6] 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..87a8177ca93 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=6d65132471df9e531807cb2746f8be317e22a343b9385bbe11c9ce7f0d2fc848
 
 if [ "$CHROOT_READY" ]; then
 	hostmakedepends="perl gettext tar"

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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (6 preceding siblings ...)
  2020-04-22 15:07 ` [PR PATCH] [Updated] " sgn
@ 2020-04-22 16:00 ` sgn
  2020-04-22 16:14 ` sgn
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 16:00 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 417 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 

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


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: 14078 bytes --]

From f18a85c7965d6d18a9088a30778481eb5d43fd17 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 20:59:26 +0700
Subject: [PATCH 1/7] xbps-src: use $XBPS_GIT_CMD for git

---
 common/environment/setup/git.sh                | 18 ++++++++----------
 .../hooks/post-install/05-generate-gitrevs.sh  | 12 ++++--------
 xbps-src                                       |  5 ++---
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..a2f7f0a28ee 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -1,19 +1,17 @@
 # If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
 # only run this, if SOURCE_DATE_EPOCH isn't set.
+
+if [ -z "$XBPS_GIT_CMD" ]; then
+	msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
+fi
+
 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}" -a -n "$IN_CHROOT" ]; then
 	# 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 $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; 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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 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..754ba8865b9 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,7 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
+	local rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +14,12 @@ 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_CMD" ]; then
+		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
+	rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
 	echo "${sourcepkg}:${rev}"
 	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
 }
diff --git a/xbps-src b/xbps-src
index 459f27eb7b7..34c51bb182e 100755
--- a/xbps-src
+++ b/xbps-src
@@ -500,14 +500,13 @@ fi
 
 # Try using chroot-git then git from the host system
 if command -v chroot-git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v chroot-git)
+    export XBPS_GIT_CMD=$(command -v chroot-git)
 elif command -v git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v git)
+    export XBPS_GIT_CMD=$(command -v git)
 else
     echo "neither chroot-git or git are available in your system!" 1>&2
     exit 1
 fi
-readonly XBPS_GIT_CMD
 
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs

From d5ae22ea037dd035e0a954110edc5fd80d4277e4 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 2/7] 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 a2f7f0a28ee..a7395ef53f3 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -9,7 +9,7 @@ if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
 elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	# check if the template is under version control:
-	if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 54bfb0bf7d81218fe8a3240acee2d35a154aa3d0 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 3/7] 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 a7395ef53f3..25cddf68e91 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -12,6 +12,7 @@ elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
+		export SOURCE_DATE_EPOCH="$($XBPS_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 458850fed073358d6d49c296ee92f7a26755e3b1 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 4/7] 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 25cddf68e91..8a45c5dd28b 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -7,9 +7,12 @@ fi
 
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	fi
 	# check if the template is under version control:
-	if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	if [ -n "$basepkg" -a -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |

From aa7875a7dce477b4e81d323fe147b0255424eccf 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 5/7] 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                  | 12 ++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 10 ++++------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 8a45c5dd28b..8372461247e 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -19,3 +19,15 @@ 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"
+	else
+		export XBPS_GIT_REVS="$($XBPS_GIT_CMD -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 754ba8865b9..c5a51f0d101 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 rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,12 +13,11 @@ hook() {
 		return
 	fi
 
-	if [ -z "$XBPS_GIT_CMD" ]; then
-		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "BUG: XBPS_GIT_REVS is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($XBPS_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 d16b394cadf4f8034139d5444a7a4d49766bbad7 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 22:33:52 +0700
Subject: [PATCH 6/7] Revert "chroot-git: simplify and avoid gettext
 dependency."

This reverts commit aa1e576abe9b001879da67da2728e13d71be025d.
Fix cross-compile chroot-git.
---
 srcpkgs/chroot-git/template | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index e685ed7dfa1..ebc1e5023a2 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -5,8 +5,8 @@ revision=1
 bootstrap=yes
 wrksrc="git-${version}"
 build_style=gnu-configure
-configure_args="--with-zlib=$XBPS_MASTERDIR/usr --without-curl
- --without-openssl --without-python --without-expat --without-tcltk
+configure_args="--without-curl --without-openssl
+ --without-python --without-expat --without-tcltk
  ac_cv_lib_curl_curl_global_init=no ac_cv_lib_expat_XML_ParserCreate=no"
 makedepends="zlib-devel"
 short_desc="GIT Tree History Storage Tool -- for xbps-src use"
@@ -18,6 +18,8 @@ checksum=9ece0dcb07a5e0d7366a92b613b201cca11ae368ab7687041364b3e756e495d6
 
 if [ "$CHROOT_READY" ]; then
 	hostmakedepends="perl gettext tar"
+else
+	configure_args+=" --with-zlib=${XBPS_MASTERDIR}/usr"
 fi
 
 post_configure() {

From f189f60559d299596dac1c136bb61d208c3e491d 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 7/7] 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 ebc1e5023a2..4f471ad2b7b 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=6d65132471df9e531807cb2746f8be317e22a343b9385bbe11c9ce7f0d2fc848
 
 if [ "$CHROOT_READY" ]; then
 	hostmakedepends="perl gettext tar"

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (7 preceding siblings ...)
  2020-04-22 16:00 ` sgn
@ 2020-04-22 16:14 ` sgn
  2020-04-22 16:15 ` sgn
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 16:14 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617878315

Comment:
I  tempted to include this patch:
```diff
diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index 4f471ad2b7..b0d5c6d9f1 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -5,9 +5,6 @@ revision=1
 bootstrap=yes
 wrksrc="git-${version}"
 build_style=gnu-configure
-configure_args="--without-curl --without-openssl
- --without-python --without-expat --without-tcltk
- ac_cv_lib_curl_curl_global_init=no ac_cv_lib_expat_XML_ParserCreate=no"
 makedepends="zlib-devel"
 short_desc="GIT Tree History Storage Tool -- for xbps-src use"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -17,17 +14,34 @@ distfiles="https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz"
 checksum=6d65132471df9e531807cb2746f8be317e22a343b9385bbe11c9ce7f0d2fc848
 
 if [ "$CHROOT_READY" ]; then
-	hostmakedepends="perl gettext tar"
-else
-	configure_args+=" --with-zlib=${XBPS_MASTERDIR}/usr"
+	hostmakedepends="perl tar"
 fi
 
-post_configure() {
+do_configure() {
 	cat <<-EOF >config.mak
+	prefix=/usr
+	CC = $CC
+	CFLAGS = $CFLAGS
+	CPPFLAGS = $CPPFLAGS
+	LDFLAGS = $LDFLAGS
 	CC_LD_DYNPATH=-L
 	NO_INSTALL_HARDLINKS=Yes
 	NO_GETTEXT=Yes
+	NO_CURL=Yes
+	NO_OPENSSL=Yes
+	NO_PYTHON=Yes
+	NO_EXPAT=Yes
+	NO_TCLTK=Yes
+	USE_LIBPCRE1 =
+	USE_LIBPCRE2 =
 	EOF
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		cat <<-EOF >>config.mak
+		ICONV_OMITS_BOM=Yes
+		NO_REGEX=NeedsStartEnd
+		EOF
+	fi
 }
 
 do_install() {
```

to get rid of configure stuff, since it's recommended by upstream
https://lore.kernel.org/git/xmqqefxe33t5.fsf@gitster.mtv.corp.google.com/
https://lore.kernel.org/git/20200401221835.GH2224@szeder.dev/



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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (8 preceding siblings ...)
  2020-04-22 16:14 ` sgn
@ 2020-04-22 16:15 ` sgn
  2020-04-22 16:28 ` sgn
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 16:15 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617878315

Comment:
I  tempted to include this patch (I haven't checked if setting CC, etc.. is required):
```diff
diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index 4f471ad2b7..b0d5c6d9f1 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -5,9 +5,6 @@ revision=1
 bootstrap=yes
 wrksrc="git-${version}"
 build_style=gnu-configure
-configure_args="--without-curl --without-openssl
- --without-python --without-expat --without-tcltk
- ac_cv_lib_curl_curl_global_init=no ac_cv_lib_expat_XML_ParserCreate=no"
 makedepends="zlib-devel"
 short_desc="GIT Tree History Storage Tool -- for xbps-src use"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -17,17 +14,34 @@ distfiles="https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz"
 checksum=6d65132471df9e531807cb2746f8be317e22a343b9385bbe11c9ce7f0d2fc848
 
 if [ "$CHROOT_READY" ]; then
-	hostmakedepends="perl gettext tar"
-else
-	configure_args+=" --with-zlib=${XBPS_MASTERDIR}/usr"
+	hostmakedepends="perl tar"
 fi
 
-post_configure() {
+do_configure() {
 	cat <<-EOF >config.mak
+	prefix=/usr
+	CC = $CC
+	CFLAGS = $CFLAGS
+	CPPFLAGS = $CPPFLAGS
+	LDFLAGS = $LDFLAGS
 	CC_LD_DYNPATH=-L
 	NO_INSTALL_HARDLINKS=Yes
 	NO_GETTEXT=Yes
+	NO_CURL=Yes
+	NO_OPENSSL=Yes
+	NO_PYTHON=Yes
+	NO_EXPAT=Yes
+	NO_TCLTK=Yes
+	USE_LIBPCRE1 =
+	USE_LIBPCRE2 =
 	EOF
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		cat <<-EOF >>config.mak
+		ICONV_OMITS_BOM=Yes
+		NO_REGEX=NeedsStartEnd
+		EOF
+	fi
 }
 
 do_install() {
```

to get rid of configure stuff, since it's recommended by upstream
https://lore.kernel.org/git/xmqqefxe33t5.fsf@gitster.mtv.corp.google.com/
https://lore.kernel.org/git/20200401221835.GH2224@szeder.dev/



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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (9 preceding siblings ...)
  2020-04-22 16:15 ` sgn
@ 2020-04-22 16:28 ` sgn
  2020-04-22 16:30 ` sgn
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 16:28 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617878315

Comment:
I  tempted to include this patch for chroot-git:
```diff
diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index 4f471ad2b7..8c7c2af6dd 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -4,10 +4,7 @@ version=2.26.2
 revision=1
 bootstrap=yes
 wrksrc="git-${version}"
-build_style=gnu-configure
-configure_args="--without-curl --without-openssl
- --without-python --without-expat --without-tcltk
- ac_cv_lib_curl_curl_global_init=no ac_cv_lib_expat_XML_ParserCreate=no"
+build_style=gnu-makefile
 makedepends="zlib-devel"
 short_desc="GIT Tree History Storage Tool -- for xbps-src use"
 maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -17,17 +14,34 @@ distfiles="https://www.kernel.org/pub/software/scm/git/git-${version}.tar.xz"
 checksum=6d65132471df9e531807cb2746f8be317e22a343b9385bbe11c9ce7f0d2fc848
 
 if [ "$CHROOT_READY" ]; then
-	hostmakedepends="perl gettext tar"
-else
-	configure_args+=" --with-zlib=${XBPS_MASTERDIR}/usr"
+	hostmakedepends="perl tar"
 fi
 
-post_configure() {
+do_configure() {
 	cat <<-EOF >config.mak
+	prefix=/usr
+	CC = $CC
+	CFLAGS = $CFLAGS
+	CPPFLAGS = $CPPFLAGS
+	LDFLAGS = $LDFLAGS
 	CC_LD_DYNPATH=-L
 	NO_INSTALL_HARDLINKS=Yes
 	NO_GETTEXT=Yes
+	NO_CURL=Yes
+	NO_OPENSSL=Yes
+	NO_PYTHON=Yes
+	NO_EXPAT=Yes
+	NO_TCLTK=Yes
+	USE_LIBPCRE1 =
+	USE_LIBPCRE2 =
 	EOF
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		cat <<-EOF >>config.mak
+		ICONV_OMITS_BOM=Yes
+		NO_REGEX=NeedsStartEnd
+		EOF
+	fi
 }
 
 do_install() {
```

to get rid of configure stuff, since it's recommended by upstream
https://lore.kernel.org/git/xmqqefxe33t5.fsf@gitster.mtv.corp.google.com/

But it's not in scope of this PR.



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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (10 preceding siblings ...)
  2020-04-22 16:28 ` sgn
@ 2020-04-22 16:30 ` sgn
  2020-04-22 16:41 ` Piraty
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-22 16:30 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617887759

Comment:
@Piraty You may be interested in this PR.

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (11 preceding siblings ...)
  2020-04-22 16:30 ` sgn
@ 2020-04-22 16:41 ` Piraty
  2020-04-26  1:19 ` [PR PATCH] [Updated] " sgn
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Piraty @ 2020-04-22 16:41 UTC (permalink / raw)
  To: ml


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

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-617894407

Comment:
i am :)  saw it already, yet have to test

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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (12 preceding siblings ...)
  2020-04-22 16:41 ` Piraty
@ 2020-04-26  1:19 ` sgn
  2020-04-26  1:20 ` sgn
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-26  1:19 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 417 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 

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


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: 12292 bytes --]

From 54eca7a5a4c2fcc670f6cc7e420677bbc417dd56 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 20:59:26 +0700
Subject: [PATCH 1/6] xbps-src: use $XBPS_GIT_CMD for git

---
 common/environment/setup/git.sh                | 18 ++++++++----------
 .../hooks/post-install/05-generate-gitrevs.sh  | 12 ++++--------
 xbps-src                                       |  5 ++---
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..a2f7f0a28ee 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -1,19 +1,17 @@
 # If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
 # only run this, if SOURCE_DATE_EPOCH isn't set.
+
+if [ -z "$XBPS_GIT_CMD" ]; then
+	msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
+fi
+
 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}" -a -n "$IN_CHROOT" ]; then
 	# 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 $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; 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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 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..754ba8865b9 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,7 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
+	local rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +14,12 @@ 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_CMD" ]; then
+		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
+	rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
 	echo "${sourcepkg}:${rev}"
 	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
 }
diff --git a/xbps-src b/xbps-src
index 459f27eb7b7..34c51bb182e 100755
--- a/xbps-src
+++ b/xbps-src
@@ -500,14 +500,13 @@ fi
 
 # Try using chroot-git then git from the host system
 if command -v chroot-git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v chroot-git)
+    export XBPS_GIT_CMD=$(command -v chroot-git)
 elif command -v git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v git)
+    export XBPS_GIT_CMD=$(command -v git)
 else
     echo "neither chroot-git or git are available in your system!" 1>&2
     exit 1
 fi
-readonly XBPS_GIT_CMD
 
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs

From 63edd0055d946a9c2f73eff4926272547c69d7d4 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 2/6] 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 a2f7f0a28ee..a7395ef53f3 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -9,7 +9,7 @@ if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
 elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	# check if the template is under version control:
-	if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 318f29c7fc1373456c469c83f40429be85c32515 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 3/6] 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 a7395ef53f3..25cddf68e91 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -12,6 +12,7 @@ elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
+		export SOURCE_DATE_EPOCH="$($XBPS_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 e6896d263063a76e5ef5bc84337720451d4f8b67 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 4/6] 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 25cddf68e91..8a45c5dd28b 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -7,9 +7,12 @@ fi
 
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	fi
 	# check if the template is under version control:
-	if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	if [ -n "$basepkg" -a -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |

From e484779124be5a137137e47051cd4d95c25ad428 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 5/6] 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                  | 12 ++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 10 ++++------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 8a45c5dd28b..8372461247e 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -19,3 +19,15 @@ 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"
+	else
+		export XBPS_GIT_REVS="$($XBPS_GIT_CMD -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 754ba8865b9..c5a51f0d101 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 rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,12 +13,11 @@ hook() {
 		return
 	fi
 
-	if [ -z "$XBPS_GIT_CMD" ]; then
-		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "BUG: XBPS_GIT_REVS is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($XBPS_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 275e4938eddd15e3aa815bc2b26163fc9f759e69 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: Sun, 26 Apr 2020 08:19:08 +0700
Subject: [PATCH 6/6] chroot-git: test new git info system

---
 srcpkgs/chroot-git/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/chroot-git/template b/srcpkgs/chroot-git/template
index 03b79a9ccce..a71a0e62251 100644
--- a/srcpkgs/chroot-git/template
+++ b/srcpkgs/chroot-git/template
@@ -1,7 +1,7 @@
 # Template file for 'chroot-git'
 pkgname=chroot-git
 version=2.26.2
-revision=1
+revision=2
 bootstrap=yes
 wrksrc="git-${version}"
 build_style=gnu-configure

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (13 preceding siblings ...)
  2020-04-26  1:19 ` [PR PATCH] [Updated] " sgn
@ 2020-04-26  1:20 ` sgn
  2020-04-26  7:53 ` Piraty
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-04-26  1:20 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-619463765

Comment:
@void-linux/pkg-committers Any comment?

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (14 preceding siblings ...)
  2020-04-26  1:20 ` sgn
@ 2020-04-26  7:53 ` Piraty
  2020-05-18 11:49 ` [PR PATCH] [Updated] " sgn
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: Piraty @ 2020-04-26  7:53 UTC (permalink / raw)
  To: ml


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

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-619504297

Comment:
please wait some more. i want to test it yet

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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (15 preceding siblings ...)
  2020-04-26  7:53 ` Piraty
@ 2020-05-18 11:49 ` sgn
  2020-05-19 12:26 ` sgn
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-05-18 11:49 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 417 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 

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


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: 11586 bytes --]

From 8429dabc3e0e2d9c981715e25f7a1d039dd92374 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 20:59:26 +0700
Subject: [PATCH 1/5] xbps-src: use $XBPS_GIT_CMD for git

---
 common/environment/setup/git.sh                | 18 ++++++++----------
 .../hooks/post-install/05-generate-gitrevs.sh  | 12 ++++--------
 xbps-src                                       |  5 ++---
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..a2f7f0a28ee 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -1,19 +1,17 @@
 # If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
 # only run this, if SOURCE_DATE_EPOCH isn't set.
+
+if [ -z "$XBPS_GIT_CMD" ]; then
+	msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
+fi
+
 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}" -a -n "$IN_CHROOT" ]; then
 	# 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 $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; 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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 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..754ba8865b9 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,7 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
+	local rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +14,12 @@ 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_CMD" ]; then
+		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
+	rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
 	echo "${sourcepkg}:${rev}"
 	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
 }
diff --git a/xbps-src b/xbps-src
index 888bc3c474a..5eeb3045e35 100755
--- a/xbps-src
+++ b/xbps-src
@@ -502,14 +502,13 @@ fi
 
 # Try using chroot-git then git from the host system
 if command -v chroot-git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v chroot-git)
+    export XBPS_GIT_CMD=$(command -v chroot-git)
 elif command -v git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v git)
+    export XBPS_GIT_CMD=$(command -v git)
 else
     echo "neither chroot-git or git are available in your system!" 1>&2
     exit 1
 fi
-readonly XBPS_GIT_CMD
 
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs

From 481f668e51bc66db2f7a3beca4123cc5812c0209 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 2/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 a2f7f0a28ee..a7395ef53f3 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -9,7 +9,7 @@ if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
 elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	# check if the template is under version control:
-	if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 6f1322381e5f63807f2e9ae0b719656a1a163c56 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 3/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 a7395ef53f3..25cddf68e91 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -12,6 +12,7 @@ elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
+		export SOURCE_DATE_EPOCH="$($XBPS_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 613837b21bdc899c004a820f44fdc225f0c9924e 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 4/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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 25cddf68e91..8a45c5dd28b 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -7,9 +7,12 @@ fi
 
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	fi
 	# check if the template is under version control:
-	if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	if [ -n "$basepkg" -a -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |

From 5997bf65cde2c684cb656456ec035310480c6e7c 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 5/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                  | 12 ++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 10 ++++------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 8a45c5dd28b..8372461247e 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -19,3 +19,15 @@ 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"
+	else
+		export XBPS_GIT_REVS="$($XBPS_GIT_CMD -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 754ba8865b9..c5a51f0d101 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 rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,12 +13,11 @@ hook() {
 		return
 	fi
 
-	if [ -z "$XBPS_GIT_CMD" ]; then
-		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "BUG: XBPS_GIT_REVS is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($XBPS_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" \

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

* Re: [PR PATCH] [Updated] [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (16 preceding siblings ...)
  2020-05-18 11:49 ` [PR PATCH] [Updated] " sgn
@ 2020-05-19 12:26 ` sgn
  2020-05-19 13:19 ` sgn
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-05-19 12:26 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 417 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 

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


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: 10236 bytes --]

From 11e89fb9c97182b1e8c444390ef056345168c69c 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 20:59:26 +0700
Subject: [PATCH 1/4] xbps-src: use $XBPS_GIT_CMD for git

---
 common/environment/setup/git.sh                | 18 ++++++++----------
 .../hooks/post-install/05-generate-gitrevs.sh  | 12 ++++--------
 xbps-src                                       |  5 ++---
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 870fa984e05..a2f7f0a28ee 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -1,19 +1,17 @@
 # If XBPS_USE_BUILD_MTIME is enabled in conf file don't continue.
 # only run this, if SOURCE_DATE_EPOCH isn't set.
+
+if [ -z "$XBPS_GIT_CMD" ]; then
+	msg_error "BUG: environment/setup: XBPS_GIT_CMD is not set\n"
+fi
+
 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}" -a -n "$IN_CHROOT" ]; then
 	# 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 $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; 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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 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..754ba8865b9 100644
--- a/common/hooks/post-install/05-generate-gitrevs.sh
+++ b/common/hooks/post-install/05-generate-gitrevs.sh
@@ -3,7 +3,7 @@
 
 hook() {
 	local GITREVS_FILE=${XBPS_STATEDIR}/gitrev
-	local GIT_CMD rev
+	local rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,16 +14,12 @@ 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_CMD" ]; then
+		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($GIT_CMD rev-parse --short HEAD)"
+	rev="$($XBPS_GIT_CMD rev-parse --short HEAD)"
 	echo "${sourcepkg}:${rev}"
 	echo "${sourcepkg}:${rev}" > $GITREVS_FILE
 }
diff --git a/xbps-src b/xbps-src
index 888bc3c474a..5eeb3045e35 100755
--- a/xbps-src
+++ b/xbps-src
@@ -502,14 +502,13 @@ fi
 
 # Try using chroot-git then git from the host system
 if command -v chroot-git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v chroot-git)
+    export XBPS_GIT_CMD=$(command -v chroot-git)
 elif command -v git &>/dev/null; then
-    XBPS_GIT_CMD=$(command -v git)
+    export XBPS_GIT_CMD=$(command -v git)
 else
     echo "neither chroot-git or git are available in your system!" 1>&2
     exit 1
 fi
-readonly XBPS_GIT_CMD
 
 if [ -n "$XBPS_HOSTDIR" ]; then
     export XBPS_REPOSITORY=$XBPS_HOSTDIR/binpkgs

From 0b0d555edf7841ecce7a69a372958db5755e5399 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 2/4] 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 a2f7f0a28ee..a7395ef53f3 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -9,7 +9,7 @@ if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
 elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
 	# check if the template is under version control:
-	if $XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} status -u normal --porcelain template | grep "^?? " &> /dev/null; then
+	if [ -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 1162f735a5f32be7e9bece95c7fefa4fa316234d 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/4] 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index a7395ef53f3..5f9b157a895 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -7,9 +7,12 @@ fi
 
 if [ -n "$XBPS_USE_BUILD_MTIME" ]; then
 	unset SOURCE_DATE_EPOCH
-elif [ -z "${SOURCE_DATE_EPOCH}" -a -n "$IN_CHROOT" ]; then
+elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
+	if [ -n "$IN_CHROOT" ]; then
+		msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
+	fi
 	# check if the template is under version control:
-	if [ -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
+	if [ -n "$basepkg" -a -z "$($XBPS_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="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"

From 41306a3c59c922dd5174c8ec63423826755855c9 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/4] 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                  | 12 ++++++++++++
 common/hooks/post-install/05-generate-gitrevs.sh | 10 ++++------
 common/xbps-src/shutils/chroot.sh                |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/common/environment/setup/git.sh b/common/environment/setup/git.sh
index 5f9b157a895..13e5178ccff 100644
--- a/common/environment/setup/git.sh
+++ b/common/environment/setup/git.sh
@@ -18,3 +18,15 @@ elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
 		export SOURCE_DATE_EPOCH="$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} log --pretty='%ct' -n1 HEAD)"
 	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"
+	else
+		export XBPS_GIT_REVS="$($XBPS_GIT_CMD -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 754ba8865b9..c5a51f0d101 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 rev
 
 	# If XBPS_USE_GIT_REVS is disabled in conf file don't continue.
 	if [ -z $XBPS_USE_GIT_REVS ]; then
@@ -14,12 +13,11 @@ hook() {
 		return
 	fi
 
-	if [ -z "$XBPS_GIT_CMD" ]; then
-		msg_error "BUG: post-install: XBPS_GIT_CMD is not set\n"
+	if [ -z "$XBPS_GIT_REVS" ]; then
+		msg_error "BUG: XBPS_GIT_REVS is not set\n"
 	fi
 
 	cd $XBPS_SRCPKGDIR
-	rev="$($XBPS_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" \

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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (17 preceding siblings ...)
  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
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-05-19 13:19 UTC (permalink / raw)
  To: ml


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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-630812589

Comment:
@Piraty I drop 2 patches, 1 that replaces git-log and the other one for testing.

If no-one complains, I'll push this version in the weekend and see the world burnt xD

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

* Re: [PR PATCH] [Merged]: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (18 preceding siblings ...)
  2020-05-19 13:19 ` sgn
@ 2020-05-23  6:59 ` sgn
  2020-05-23 12:25 ` Piraty
  20 siblings, 0 replies; 22+ messages in thread
From: sgn @ 2020-05-23  6:59 UTC (permalink / raw)
  To: ml


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

There's a merged pull request on the void-packages repository

[RFC] Support git worktree
https://github.com/void-linux/void-packages/pull/21207

Description:
My effort to address #20393 

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


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

* Re: [RFC] Support git worktree
  2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
                   ` (19 preceding siblings ...)
  2020-05-23  6:59 ` [PR PATCH] [Merged]: " sgn
@ 2020-05-23 12:25 ` Piraty
  20 siblings, 0 replies; 22+ messages in thread
From: Piraty @ 2020-05-23 12:25 UTC (permalink / raw)
  To: ml


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

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/21207#issuecomment-633042895

Comment:
let it burn

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

end of thread, back to index

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 16:25 [PR PATCH] [RFC] Support git worktree sgn
2020-04-21 16:43 ` xtraeme
2020-04-22  0:01 ` sgn
2020-04-22  0:44 ` sgn
2020-04-22  0:49 ` [PR PATCH] [Updated] " sgn
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

Github messages for voidlinux

Archives are clonable: git clone --mirror http://inbox.vuxu.org/voidlinux-github

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.github.voidlinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git