From patchwork Wed Sep 13 00:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 53794 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DCFAF27BBEA; Wed, 13 Sep 2023 23:53:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 01F7127BBE9 for ; Wed, 13 Sep 2023 23:53:39 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgYjD-00036i-0o; Wed, 13 Sep 2023 18:52:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgYjB-000366-6e for guix-patches@gnu.org; Wed, 13 Sep 2023 18:52:57 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgYjA-000124-VP for guix-patches@gnu.org; Wed, 13 Sep 2023 18:52:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgYjF-0005Mx-TZ for guix-patches@gnu.org; Wed, 13 Sep 2023 18:53:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65352] Fix time-machine and network Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 13 Sep 2023 22:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65352 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 65352@debbugs.gnu.org, Maxim Cournoyer Received: via spool by 65352-submit@debbugs.gnu.org id=B65352.169464554720578 (code B ref 65352); Wed, 13 Sep 2023 22:53:01 +0000 Received: (at 65352) by debbugs.gnu.org; 13 Sep 2023 22:52:27 +0000 Received: from localhost ([127.0.0.1]:36296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYih-0005Lk-2m for submit@debbugs.gnu.org; Wed, 13 Sep 2023 18:52:27 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:39175) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYid-0005LT-AW for 65352@debbugs.gnu.org; Wed, 13 Sep 2023 18:52:26 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-403c5bcffc4so911245e9.1 for <65352@debbugs.gnu.org>; Wed, 13 Sep 2023 15:52:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694645532; x=1695250332; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IBhjqwB2hC2JQoQ/JMbcvE1d5lXrBnXkJBzAwom+G9c=; b=RbWMEO4cGY4vSkaATsIjhxyOQhv96uaE1ntN5RlQ/a1K2F9WK+4dGbDgb09gITk203 QKtKecE9e6GdQAgtwDJoN03A8BPAvbWXn0WiRH321l6w40pJ9tMK/jEzRfjt1PsGzVrX o/bAN73ldq+QKHlW29BFNqDMmrZESU9TehdPh6tM796bgZoQ05djSo+9Y8QebYEFFZ2+ BPXFUUUoBY1t5jFHvXFU1HgN6NC/PIEkswtrAdG/A0vqqYscy8Z0/v84aWVNKxgAKHl1 uMEPPDMpy6iiJCtfaSF3/2U5TIWQruXn6IwXoNyY1F1nCei0gju9WflbW3te9ao4U3jy w6AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694645532; x=1695250332; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IBhjqwB2hC2JQoQ/JMbcvE1d5lXrBnXkJBzAwom+G9c=; b=Ph34fQzDiMHe/dvvjDFFdw6/Hk99I3OAw6727L7NW7a6kPNwk+s4YMfesVhEBDqT2w yyQpkjJYNLPRgHK7NuNuRzctkPAjWBxgSF49hBruMl2mh8SSasb+Vukab210CZN7mJ41 EpH4DS2bkOLX7zbcy0tLuSQhCbbzv/qqmtq5blQidGhbDgf0q1jEtt5U2rh57/02VxuH fhgianydhXufHeqOAUW/SLXP2lIApohmgU6vxXiZtr+o73dPhPcGpsQgeEV+1Y8C4rw7 ABHvffSYfBuW8xzPctxEBYtt5QRNQLZeGpIXWlRZoslNnFr7lK9Q3RA2mCDncEuHuHPG 0p3Q== X-Gm-Message-State: AOJu0Yz+bPEBOgma4IJyBpUYhmnIYo3cwQ3LIUmJF9xXg+xaJnEQQyR9 GLjIYvUzMaaPOOjX7s8qcOc= X-Google-Smtp-Source: AGHT+IGi/KEEdP8ZkKHcUkZe7bgGnoUFLHziix5hMmCVrP9Ckd1e6l3MSNmwC1tCByGIn9Lb2HlYiQ== X-Received: by 2002:adf:ebc8:0:b0:317:7238:336a with SMTP id v8-20020adfebc8000000b003177238336amr3015358wrn.5.1694645531645; Wed, 13 Sep 2023 15:52:11 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id x2-20020adfec02000000b003179d7ed4f3sm95419wrn.12.2023.09.13.15.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:52:11 -0700 (PDT) From: Simon Tournier In-Reply-To: <875y4dltgm.fsf_-_@gnu.org> References: <86ledjoaly.fsf@gmail.com> <32d3fb5066e0b20e200dabef0fba897634e21dda.1694009405.git.zimon.toutoune@gmail.com> <875y4dltgm.fsf_-_@gnu.org> Date: Wed, 13 Sep 2023 02:32:17 +0200 Message-ID: <86a5tqzze6.fsf@gmail.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi Ludo, On Wed, 13 Sep 2023 at 22:16, Ludovic Courtès wrote: >> + (('commit . (? commit-id? commit)) >> + (let ((oid (string->oid commit))) >> + (->bool (commit-lookup repository oid)))) >> + ((or ('tag . str) >> + ('tag-or-commit . str)) >> + (false-if-git-not-found >> + (->bool (resolve-reference repository ref)))) > > IIUC, the differences compared to what we had are: > > 1. 'tag references are now handled on the fast path > (‘reference-available?’ can return #t); > > 2. short commit strings are now always on the slow path > (‘reference-available?’ always returns #f). > > Is that correct? No, or I am missing some details. > It would be nice to have #1 without #2. It’s already the case because of that: (option '("commit") #t #f (lambda (opt name arg result) (alist-cons 'ref `(tag-or-commit . ,arg) result))) Currently, the heuristic to determine if it is a tag or a commit is implemented by ’resolve-reference’. Somehow, considering the command-line parser, the alternative is: #1 and #2 on the fast path (the patch) or #1 and #2 on the slow path (the current implementation) Let ’pk’ (see below) to convince you. :-) Before the proposed patch: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix time-machine --commit=v1.4.0 -- describe ;;; (ref (tag-or-commit . "v1.4.0")) ;;; (reference-available? #f) ;;; (remote-fetch NETWORK) C-c C-c $ ./pre-inst-env guix time-machine --commit=8e2f32c -- describe ;;; (ref (tag-or-commit . "8e2f32c")) ;;; (reference-available? #f) ;;; (remote-fetch NETWORK) C-c C-c --8<---------------cut here---------------end--------------->8--- After the proposed patch: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix time-machine --commit=v1.4.0 -- describe ;;; (ref (tag-or-commit . "v1.4.0")) ;;; (reference-available? #t) guix 8e2f32c repository URL: https://git.savannah.gnu.org/git/guix.git commit: 8e2f32cee982d42a79e53fc1e9aa7b8ff0514714 $ ./pre-inst-env guix time-machine --commit=8e2f32c -- describe ;;; (ref (tag-or-commit . "8e2f32c")) ;;; (reference-available? #t) guix 8e2f32c repository URL: https://git.savannah.gnu.org/git/guix.git commit: 8e2f32cee982d42a79e53fc1e9aa7b8ff0514714 --8<---------------cut here---------------end--------------->8--- Cheers, simon --8<---------------cut here---------------start------------->8--- --8<---------------cut here---------------end--------------->8--- diff --git a/guix/git.scm b/guix/git.scm index 1cb87a45607b..c927555cce18 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -481,6 +481,8 @@ (define* (update-cached-checkout url (repository-open cache-directory) (clone/swh-fallback url ref cache-directory)))) ;; Only fetch remote if it has not been cloned just before. + (pk 'ref ref) + (pk 'reference-available? (reference-available? repository ref)) (when (and cache-exists? (not (reference-available? repository ref))) (remote-fetch (remote-lookup repository "origin")