From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CA4pAkr+0192aQAA0tVLHw (envelope-from ) for ; Fri, 11 Dec 2020 23:18:34 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 6IeIOUn+01/mSAAAB5/wlQ (envelope-from ) for ; Fri, 11 Dec 2020 23:18:33 +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 7F229940429 for ; Fri, 11 Dec 2020 23:18:33 +0000 (UTC) Received: from localhost ([::1]:41304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knrgG-00044l-19 for larch@yhetil.org; Fri, 11 Dec 2020 18:18:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knrRG-0001st-1M for bug-guix@gnu.org; Fri, 11 Dec 2020 18:03:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:60256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1knrRF-0007D0-Pk for bug-guix@gnu.org; Fri, 11 Dec 2020 18:03:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1knrRF-00053n-Kx for bug-guix@gnu.org; Fri, 11 Dec 2020 18:03:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#45187: git download defaults to origin/master Resent-From: Kyle Meyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 11 Dec 2020 23:03: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.160772772719390 (code B ref 45187); Fri, 11 Dec 2020 23:03:01 +0000 Received: (at 45187) by debbugs.gnu.org; 11 Dec 2020 23:02:07 +0000 Received: from localhost ([127.0.0.1]:43569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knrQM-00052f-UO for submit@debbugs.gnu.org; Fri, 11 Dec 2020 18:02:07 -0500 Received: from out0.migadu.com ([94.23.1.103]:18226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1knrQJ-00052V-Tr for 45187@debbugs.gnu.org; Fri, 11 Dec 2020 18:02:06 -0500 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=1607727722; 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:references:references; bh=iG2LJjNKZknfLauMSUlJwRPYgcahh6ruptycDFUcpPw=; b=QtVQR5dZK8j/A6mKIsSp4jgiL23MjHnJVssIIOKH2W7cwRBAb4zeS5zj6XbGxmgim87hao SbodyjiyCIBi477FaI2/i5Ylvv2uTZrUTyEZjv/NdVVqeIFadmFA2Q3FhPU7dP7mTbzJ8Z L9PXkyqzXHvWc+RBdpBVsryFOqfPs42a7g0Nm/rRDdMzk3TvGVEi5e2SF941VdTcdWgIjh ZlXrXIIPWjQLma6lNgLECMim7+gCoT3TiZKPSfI9QV9k+7YsnQL1h7nANW2HfkBC6KrH+q ManJLfeL2qRI6QrOztoP2bMZ9BZwvufOMxA9c0HhfTi18eONgVwCMtNsW07Xfw== From: Kyle Meyer In-Reply-To: <878sa4vyxb.fsf@elephly.net> References: <878sa4vyxb.fsf@elephly.net> Message-ID: <87v9d8dk0r.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 Date: Fri, 11 Dec 2020 23:02:02 GMT 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 X-Migadu-Spam-Score: -1.30 Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=kyleam.com header.s=key1 header.b=QtVQR5dZ; 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: 7F229940429 X-Spam-Score: -1.30 X-Migadu-Scanner: scn1.migadu.com X-TUID: AkkNEDsDf0iS Ricardo Wurmus writes: > Importing https://github.com/immunogenomics/scpost with the CRAN > importer fails, because the git repository does not have an > origin/master branch. This repository only has a =E2=80=9Cmain=E2=80=9D = branch. > > Arguably, this shouldn=E2=80=99t matter, but (guix git) has the =E2=80=9C= master=E2=80=9D name > set up as the default. When cloning a repository it may be better to > fetch everything and select the default branch =E2=80=94 whichever name i= t may > have. One option may be to use the remote HEAD symref. That's probably the best indicator of what the primary branch is. In a clone, it doesn't necessarily match HEAD on the remote, because users may change it to another branch they're interested in, but that isn't really relevant to these behind-the-scenes checkouts. Here's a quick and dirty demo that makes your reproducer work. A real patch in this direction would of course look very different. diff --git a/guix/git.scm b/guix/git.scm index ca77b9f54b..7320c0d6c8 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -207,6 +207,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 @@ -320,7 +323,7 @@ (define (reference-available? repository ref) =20 (define* (update-cached-checkout url #:key - (ref '(branch . "master")) + (ref '(symref . "refs/remotes/origin/HEAD= ")) recursive? (check-out? #t) starting-commit @@ -395,7 +398,7 @@ (define* (latest-repository-commit store url (log-port (%make-void-port "w")) (cache-directory (%repository-cache-directory)) - (ref '(branch . "master"))) + (ref '(symref . "refs/remotes/origin/HE= AD"))) "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.