From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MPV3NfDhb2C/PwEAgWs5BA (envelope-from ) for ; Fri, 09 Apr 2021 07:11:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id GC1AL/Dhb2BzSQAAbx9fmQ (envelope-from ) for ; Fri, 09 Apr 2021 05:11:12 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8E4C41A055 for ; Fri, 9 Apr 2021 07:11:11 +0200 (CEST) Received: from localhost ([::1]:55592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUjQE-00053c-Ae for larch@yhetil.org; Fri, 09 Apr 2021 01:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUjQ6-00053P-D1 for bug-guix@gnu.org; Fri, 09 Apr 2021 01:11:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37386) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUjQ6-0006cU-53 for bug-guix@gnu.org; Fri, 09 Apr 2021 01:11:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lUjQ5-0005ku-W0 for bug-guix@gnu.org; Fri, 09 Apr 2021 01:11:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#45187: [PATCH] git: Update cached checkout to the remote HEAD by default. References: <878sa4vyxb.fsf@elephly.net> Resent-From: Kyle Meyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 09 Apr 2021 05:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45187 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ricardo Wurmus Received: via spool by 45187-submit@debbugs.gnu.org id=B45187.161794503321966 (code B ref 45187); Fri, 09 Apr 2021 05:11:01 +0000 Received: (at 45187) by debbugs.gnu.org; 9 Apr 2021 05:10:33 +0000 Received: from localhost ([127.0.0.1]:48932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUjPd-0005iD-7c for submit@debbugs.gnu.org; Fri, 09 Apr 2021 01:10:33 -0400 Received: from out1.migadu.com ([91.121.223.63]:17209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUjPX-0005i0-Kb for 45187@debbugs.gnu.org; Fri, 09 Apr 2021 01:10:31 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1617945025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to; bh=DK3jNEC1QeWp2hbqijJ/lPanKFDFa98PkL8E1ba/mSs=; b=MqGlsorgx2Z5tiE7BeMc77VBKgZswLANJJsJ0lSuQCaJGWI9CgGNjOUdUv6v5pmMHZLoUu FFdFJP6vSuzR4XehuQz+PpVmphwok9ZTy046RgENpux7l7bzcVrIb6cEBIw2UsRJOgiRCR EX6rzc6JRBZZZPNk4MF5f3/pDAcHELgsLhR/GnhPy8iyWxpHWrcTQFcf/ar8Ww6bTXCHg1 pyOirmyDGz+H1/p9eZ2CeGqux4i0SRZCBrgrsQPpIKEWI8S0SbPMIqxONI7vyIwoPq2WZs fW+Vg8MQ8dOWWzY9qxczKGX4PleTJH8v+noA7DlNuQCgHCRW5NW+5rxDoKtuyQ== From: Kyle Meyer In-Reply-To: <87ft00ycg8.fsf@elephly.net> Date: Fri, 09 Apr 2021 01:10:22 -0400 Message-ID: <875z0wt54x.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Auth-User: kyle@kyleam.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 45187@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617945072; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DK3jNEC1QeWp2hbqijJ/lPanKFDFa98PkL8E1ba/mSs=; b=aHtVQNQ8nby6/EqBBpwawG/yqgkZyzB+MZVxXNFrsGM9Hj2Q36L5eBFs1ntWVTJcHqbIjY Zc6+WHKdFC16Hc//l4URFMWVyO1KygZLr6svLsFUcR9evjAherKlgGGa+eINZGbiH8tRDK lKaxahWVnZe0t4K1G4kqSSqXXWsFWfQiWE5tdCAm2zK7f0WQrAkNc6CUhBlruo17d3gMgS gURWkJfzrtFvWXOi55DBEFcshPsGaoW0Z+k3Ezj+KOpgaiDDxNjFQbuJQE7LSThNejmH1s aw7tYxnenYLYVckPjK+eMPRF3ca0dthZAvkiHOxQ2p2gCzaplleIvnrTnNNIDw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617945072; a=rsa-sha256; cv=none; b=FETFDvob1ZTCGLiBdDChlQ/MCWLIcOKDdWh0wHROTcvTzoPiU6tYbvYsIFeiUiYgSNj7EK q0TRvGvHBky0sT+E8EGdc7Yo4TI2+VygxHQgp0kXb+2yK+///b/xzyrbTatatFjKbOzEF7 5ZJsyqwvfMhb0WbxkSB4K58ZFBur6gJE2OJeogLt4G3aOYp5C2fcT0AF+b+15Xs5IyRvZ7 Xr27mHfFMQtI/qGxdgdbwJUYYIlJC8hmDwqM7a9y8eUOOaFJ5AcmKh2kjpG4iZRBvL0svh 29czNIfZrZhjI3v5ywOxRrrrfQuKLU6HbmTFjEIIdE+0+LKK932d3o2CxxLKbQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=MqGlsorg; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -1.44 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=MqGlsorg; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 8E4C41A055 X-Spam-Score: -1.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8p+LQ+2wGXnO Ricardo Wurmus writes: > I=E2=80=99m a bit lost: is there something we need to decide on to move t= his > forward? I guess the main open question is whether to rework things to use revparse-single as Marius suggested. And if we don't, another question (raised by me) is whether there's a better approach than adding the additional symref key/field. As I said upthread, "without the introduction of something like `symref', I'm not spotting a straightforward way to deal with refs/remotes/origin/HEAD in resolve-reference". > (The issue has become a bit more pressing as origin/main is the new > default on Github since a while.) Right, thanks for bumping this. Here's my attempt to put together a complete patch. I've tested this with $ guix import cran -r -a git https://github.com/immunogenomics/scpost as well as a few `guix build --with-(branch|commit)=3D...' invocations. Running `make check', I don't see any new failures, though I see the same two failures ("channel-news, one entry" and "tests/guix-git-authenticate.sh") on master and with this patch. I haven't yet looked more closely at those. -- >8 -- Subject: [PATCH] git: Update cached checkout to the remote HEAD by default. Fixes . Reported by Ricardo Wurmus . update-cached-checkout hard codes "master" as the default branch, leading t= o a failure when the clone doesn't have a "master" branch. Instead use the rem= ote HEAD symref as an indicator of what the primary branch is. * guix/git.scm (resolve-reference): Support resolving symrefs. (update-cached-checkout, latest-repository-commit): Default to the remote H= EAD symref. (): Add symref field that defaults to "HEAD", and change bran= ch field's default to #f. (git-checkout-compiler): Handle symref field of . --- guix/git.scm | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index 1820036f25..6b410ed42f 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2017, 2020 Mathieu Othacehe ;;; Copyright =C2=A9 2018, 2019, 2020, 2021 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2021 Kyle Meyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -209,6 +210,9 @@ (define (resolve-reference repository ref) (let ((oid (reference-target (branch-lookup repository branch BRANCH-REMOTE)))) (object-lookup repository oid))) + (('symref . symref) + (let ((oid (reference-name->oid repository symref))) + (object-lookup repository oid))) (('commit . commit) (let ((len (string-length commit))) ;; 'object-lookup-prefix' appeared in Guile-Git in Mar. 2018, so = we @@ -340,7 +344,7 @@ (define (delete-checkout directory) =20 (define* (update-cached-checkout url #:key - (ref '(branch . "master")) + (ref '(symref . "HEAD")) recursive? (check-out? #t) starting-commit @@ -354,8 +358,9 @@ (define* (update-cached-checkout url to REF, and the relation of the new commit relative to STARTING-COMMIT (if provided) as returned by 'commit-relation'. =20 -REF is pair whose key is [branch | commit | tag | tag-or-commit ] and value -the associated data: [ | | | ]. +REF is pair whose key is [branch | commit | tag | tag-or-commit | symref] = and +value the associated data: +[ | | | | ]. =20 When RECURSIVE? is true, check out submodules as well, if any. =20 @@ -378,6 +383,10 @@ (define* (update-cached-checkout url `(branch . ,(if (string-prefix? "origin/" branch) branch (string-append "origin/" branch)))) + (('symref . symref) + `(symref . ,(if (string-prefix? "refs/remotes/origin/" symref) + symref + (string-append "refs/remotes/origin/" symref)))) (_ ref))) =20 (with-libgit2 @@ -433,12 +442,12 @@ (define* (latest-repository-commit store url (log-port (%make-void-port "w")) (cache-directory (%repository-cache-directory)) - (ref '(branch . "master"))) + (ref '(symref . "HEAD"))) "Return two values: the content of the git repository at URL copied into= a store directory and the sha1 of the top level commit in this directory. T= he reference to be checkout, once the repository is fetched, is specified by = REF. -REF is pair whose key is [branch | commit | tag] and value the associated -data, respectively [ | | ]. +REF is pair whose key is [branch | commit | tag | symref] and value the +associated data, respectively [ | | | ]. =20 When RECURSIVE? is true, check out submodules as well, if any. =20 @@ -548,7 +557,8 @@ (define-record-type* git-checkout make-git-checkout git-checkout? (url git-checkout-url) - (branch git-checkout-branch (default "master")) + (branch git-checkout-branch (default #f)) + (symref git-checkout-symref (default "HEAD")) (commit git-checkout-commit (default #f)) ;#f | tag | commit (recursive? git-checkout-recursive? (default #f))) =20 @@ -585,11 +595,14 @@ (define-gexp-compiler (git-checkout-compiler (checkou= t ) ;; "Compile" CHECKOUT by updating the local checkout and adding it to the ;; store. (match checkout - (($ url branch commit recursive?) + (($ url branch symref commit recursive?) (latest-repository-commit* url - #:ref (if commit - `(tag-or-commit . ,commit) - `(branch . ,branch)) + #:ref (cond (commit + `(tag-or-commit . ,commit)) + (branch + `(branch . ,branch)) + (else + `(symref . ,symref))) #:recursive? recursive? #:log-port (current-error-port))))) =20 base-commit: 43c55856c876c76200cdccc1211868b92352c4ae --=20 2.31.1