From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0FONF4YbE2GrEwAAgWs5BA (envelope-from ) for ; Wed, 11 Aug 2021 02:36:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eL7oEoYbE2GoKwAA1q6Kng (envelope-from ) for ; Wed, 11 Aug 2021 00:36:22 +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 89B1F1D9BC for ; Wed, 11 Aug 2021 02:36:21 +0200 (CEST) Received: from localhost ([::1]:58276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDcEG-0005zq-0p for larch@yhetil.org; Tue, 10 Aug 2021 20:36:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDcDy-0005hW-9F for guix-patches@gnu.org; Tue, 10 Aug 2021 20:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDcDy-000379-2M for guix-patches@gnu.org; Tue, 10 Aug 2021 20:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDcDx-0005GO-UR for guix-patches@gnu.org; Tue, 10 Aug 2021 20:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49252] [PATCH] Channels defaulting to HEAD instead of =?UTF-8?Q?=E2=80=98master=E2=80=99?= Resent-From: Kyle Meyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 11 Aug 2021 00:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49252 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Ricardo Wurmus , 49252@debbugs.gnu.org Received: via spool by 49252-submit@debbugs.gnu.org id=B49252.162864211220174 (code B ref 49252); Wed, 11 Aug 2021 00:36:01 +0000 Received: (at 49252) by debbugs.gnu.org; 11 Aug 2021 00:35:12 +0000 Received: from localhost ([127.0.0.1]:32819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDcD6-0005FC-7t for submit@debbugs.gnu.org; Tue, 10 Aug 2021 20:35:12 -0400 Received: from out0.migadu.com ([94.23.1.103]:52141) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDcD0-0005Ej-JM for 49252@debbugs.gnu.org; Tue, 10 Aug 2021 20:35:07 -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=1628642100; 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=lWw3jSE2qpRMgcc0MG9K6uKLN4id4Mhi3251RlOcBmg=; b=UVgNgWVlfhrteA6JfuKXkoDze5Z3uzXIbV+EOo4QDxZ0dpCKPlXSE6N6lKfQzibLVizRym ssAIvWDnEnqHrP2eLUEfmxIbG0RfW8aYa34ylVZD6SeIHMISYmbwZl+wJRamtL+fKid85Y yxK+2JQ91B5RVBBLt7gNwUgbRvmciumUwN3Y/iNtaUe9DlpgMTUNpdtg//EisHCbs5A2Ka lA+wUaT3JL0ZrIHxG1ZzPMXY4+nWI5CNmy3pSOFp32Xo5i4kEeWH38LAdTkyrYyQceBqqp pU6UG3pKQzHR+mGzRrzTnebjmOILmBaW71aKjQecVeqGEploG/5TaYTl1S0hgQ== From: Kyle Meyer In-Reply-To: <87r1f1sp2x.fsf@gnu.org> References: <87y2auw3jo.fsf@inria.fr> <87fswo8goa.fsf@kyleam.com> <87h7g5p7yi.fsf@gnu.org> <87k0kv8qka.fsf@kyleam.com> <87wnovyobb.fsf@gnu.org> <87h7fyhwwj.fsf@kyleam.com> <87r1f1sp2x.fsf@gnu.org> Date: Tue, 10 Aug 2021 20:34:58 -0400 Message-ID: <87czqkizt9.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: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628642182; 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=lWw3jSE2qpRMgcc0MG9K6uKLN4id4Mhi3251RlOcBmg=; b=LoXrYQIhZDrsIHhyrZ0oQfylNNhTZNSgzOtonrIZDQZtI03Pre5Hw19w7KMJGHdxxDHDGL O6+TBk7GBxdGCXh2Y8FjtiF7FnYUuX1zEMH8CMwzefQW2l7dXmDeunNnK3hDv414Vyf9rj VohUoCGY0pcXmuhta0tVADF7Lw9i3TZhJyrYiCjSMjdvtLAspKj706XcDl2VEjgHcpfA2O 9JMQe7LifgUC0TlYj3qW7jtYMfvgsClOCL4FAUg5mW9rJ4zgiGEYtgU2VFj9Y3eMZo+x2U cNNhriBWIR5pIhXizbcaJbkGbfAokpslb5zxNvmHA+fJLdTSLXBlOTJJrEUAcg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628642182; a=rsa-sha256; cv=none; b=KJCYODNToOPHW7s7Xh7slTCXTa2vNWCe8EvS6NAu1+b6kmAHfTX3fmh5rDa/TEOG19oU8B +M3fkUgUhxe+uWvtj+p9dsV9FKvHsqSAyqOMG2cX4Y8MKtbZX57VYuIm4r1kE/Tm6JL0OW OVgENgj6QAloDtwgPVbxQZ0obmNDwHrVGjyD9cm9cA01H6mSkBVQQr+eo4YLjEM69UJ30t hbh2vqLllcOn3cdba8UlWXqYty7xEgPWyCrFFY5t8r/qRMfAu4jegITZ5QECf/HRODsp7w ADcy/Xc7IzIcOeGs7aPNfZz52bhI7XPphvX4F6SuLW37b/DRKnyNUShyCVWsEA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=UVgNgWVl; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=UVgNgWVl; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 89B1F1D9BC X-Spam-Score: -1.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: mWYNSXhye+xX Ludovic Court=C3=A8s writes: > Right. We can add the missing procedures in Guile-Git, but in the > meantime, maybe we could create .git/refs/origin/HEAD =E2=80=9Cby hand=E2= =80=9D? Yep, for the default branch $NAME, "ref: refs/remotes/origin/$NAME\n" can be written to .git/refs/origin/HEAD. With respect to getting the default branch, I said in my last message that I thought it'd be possible to glean the target from the remote-ls output. To flesh that out a bit: --8<---------------cut here---------------start------------->8--- (use-modules (git) (system foreign)) (define origin (remote-lookup (repository-open ".") "origin")) (remote-connect origin) (define head (car (remote-ls origin))) (define target-pt (make-pointer ((record-accessor (record-type-descriptor head) 'symref-target) head))) (if (not (null-pointer? target-pt)) (display (pointer->string target-pt))) ;; =3D> refs/heads/master --8<---------------cut here---------------end--------------->8--- And that looks like it matches what libgit2's git_remote_default_branch() does for the non-guessing case (see below), so stopping there may be sufficient for a compatibility kludge. --8<---------------cut here---------------start------------->8--- if ((error =3D git_remote_ls(&heads, &heads_len, remote)) < 0) goto done; if (heads_len =3D=3D 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) { error =3D GIT_ENOTFOUND; goto done; } if ((error =3D git_buf_sanitize(out)) < 0) return error; /* the first one must be HEAD so if that has the symref info, we're done */ if (heads[0]->symref_target) { error =3D git_buf_puts(out, heads[0]->symref_target); goto done; } /* * If there's no symref information, we have to look over them * and guess. We return the first match unless the default * branch is a candidate. Then we return the default branch. */--8<---------------cut here---------------end--------------->8---