tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] mk/git-package.mk: Improve check if update of Git archive is necessary



Hello.

I noticed that preparations to update Git-based packages in pkgsrc-wip
took increasingly long time. It occurred to me that I haven’t seen the
‘Creating cached Git archive’ step being performed for a very long time.
I took a look at pkgsrc/distfiles/git-packages and saw that most of
the archives there were stuck at 12th of April 2018, and the others
had even earlier modification dates. The date coïncides with e5fc07c8.

I analysed the change and I think I found and fixed the problem,
but I’m not confident enough to push my correction to a module
used by so many packages. Can I have it reviewed/tested please?

The following patch moves three lines and replaces
occurrences of ‘HEAD’ in them with ‘"$$revision"’.

Thanks


Git archives are supposed to be updated when update of Git working
area causes a change in ref related to the desired revision.
To achieve this, refs before and after update are compared.

Unfortunately the refs related to HEAD were probed around checkout
step, which caused the comparison to always result in a match.

This change moves the probes around fetch step which
actually updates the refs, and makes them check
the desired revision instead of hardcoded HEAD.
---
 mk/git-package.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mk/git-package.mk b/mk/git-package.mk
index a1bc778ac6..5e4c1e2701 100644
--- a/mk/git-package.mk
+++ b/mk/git-package.mk
@@ -189,10 +189,12 @@ _GIT_CMD.checkout.${repo}= \
 	  remote set-branches origin '*';				\
 	\
 	${STEP_MSG} "Updating Git working area $$extractdir.";		\
+	revision=${_GIT_REV.${repo}:Q};					\
+	rev_before=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref "$$revision"`; \
 	${_GIT_CMDLINE.${repo}} -C "$$extractdir"			\
 	  fetch ${_GIT_FETCH_FLAGS.${repo}};				\
+	rev_after=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref "$$revision"`; \
 	\
-	revision=${_GIT_REV.${repo}:Q};					\
 	checkout_date=${CHECKOUT_DATE:Q};				\
 	if [ "$$checkout_date" ]; then					\
 	  ${STEP_MSG} "Checking out $$revision at $$checkout_date.";	\
@@ -202,10 +204,8 @@ _GIT_CMD.checkout.${repo}= \
 	    checkout ${_GIT_CHECKOUT_FLAGS} "$$ref";			\
 	else								\
 	  ${STEP_MSG} "Checking out $$revision.";			\
-	  rev_before=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref HEAD`; \
 	  ${_GIT_CMDLINE.${repo}} -C "$$extractdir"			\
 	    checkout ${_GIT_CHECKOUT_FLAGS} "$$revision";		\
-	  rev_after=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref HEAD`; \
 	fi;								\
 	\
 	${STEP_MSG} "Updating submodules of $$extractdir.";		\
-- 
Mateusz Poszwa


Home | Main Index | Thread Index | Old Index