NetBSD Problem Report #58295

From mdehling@gmail.com  Tue May 28 00:23:57 2024
Return-Path: <mdehling@gmail.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0AC051A923A
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 28 May 2024 00:23:57 +0000 (UTC)
Message-Id: <CAP+FTfWpOG6bkHUYzVpwDAid8nvXVD+uo+S_bG89FTFbh8MUUQ@mail.gmail.com>
Date: Mon, 27 May 2024 19:23:54 -0500
From: Malte Dehling <mdehling@gmail.com>
To: GNATS Bugs <gnats-bugs@netbsd.org>
Subject: wip/mk/git-package.mk broken GIT_REVISION support
X-Send-Pr-Version: 3.95

>Number:         58295
>Category:       pkg
>Synopsis:       wip/mk/git-package.mk broken GIT_REVISION support
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 28 00:25:00 +0000 2024
>Originator:     Malte Dehling
>Release:        NetBSD 10.0
>Organization:
>Environment:
    NetBSD 10.0 (GENERIC) #4: Wed Apr 24 12:21:26 PDT 2024
    mdehling@nb-base-dev:/scratch/obj/sys/arch/amd64/compile/GENERIC amd64

>Description:
    For a package in wip with GIT_REPO & GIT_REVISION set (but not
    GIT_BRANCH), the "Updating Git working area" step fails every time.

    The issue is that rev_before=`git show-ref $revision` fails when
    $revision is a commit hash since git returns exit code 1.

>How-To-Repeat:

>Fix:
    The following seems to work for branches, tags, and commit hashes.
    Can someone who understands the infrastructure better confirm?

diff --git a/mk/git-package.mk b/mk/git-package.mk
index efb8491445..d1034bd7a2 100644
--- a/mk/git-package.mk
+++ b/mk/git-package.mk
@@ -190,10 +190,10 @@ _GIT_CMD.checkout.${repo}= \
 	\
 	${STEP_MSG} "Updating Git working area $$extractdir.";		\
 	revision=${_GIT_REV.${repo}:Q};					\
-	rev_before=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref
"$$revision"`; \
+	rev_before=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" rev-list -n 1
"$$revision"`; \
 	${_GIT_CMDLINE.${repo}} -C "$$extractdir"			\
 	  fetch ${_GIT_FETCH_FLAGS.${repo}};				\
-	rev_after=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" show-ref "$$revision"`; \
+	rev_after=`${_GIT_CMDLINE.${repo}} -C "$$extractdir" rev-list -n 1
"$$revision"`; \
 	\
 	checkout_date=${CHECKOUT_DATE:Q};				\
 	if [ "$$checkout_date" ]; then					\

-- 
Malte Dehling

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.