From patchwork Wed Sep 6 14:17:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 53595 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 C804B27BBEA; Wed, 6 Sep 2023 15:18:33 +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 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 CED1027BBE2 for ; Wed, 6 Sep 2023 15:18:32 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdtMH-0002JX-05; Wed, 06 Sep 2023 10:18:17 -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 1qdtM1-0002Ez-PO for guix-patches@gnu.org; Wed, 06 Sep 2023 10:18:03 -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 1qdtM1-0002XX-A4 for guix-patches@gnu.org; Wed, 06 Sep 2023 10:18:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qdtM2-0006CU-4d for guix-patches@gnu.org; Wed, 06 Sep 2023 10:18:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65352] [PATCH v2] DRAFT git: Avoid touching the network unless needed in 'reference-available?'. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Sep 2023 14:18:02 +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: Simon Tournier , 65352@debbugs.gnu.org, Maxim Cournoyer Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 65352-submit@debbugs.gnu.org id=B65352.169400984923792 (code B ref 65352); Wed, 06 Sep 2023 14:18:02 +0000 Received: (at 65352) by debbugs.gnu.org; 6 Sep 2023 14:17:29 +0000 Received: from localhost ([127.0.0.1]:37076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdtLU-0006Bg-RU for submit@debbugs.gnu.org; Wed, 06 Sep 2023 10:17:29 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:38170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdtLQ-0006BN-Dt for 65352@debbugs.gnu.org; Wed, 06 Sep 2023 10:17:28 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401ef656465so11929375e9.1 for <65352@debbugs.gnu.org>; Wed, 06 Sep 2023 07:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694009836; x=1694614636; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sw98O3dNVCOWfHSc7YY7jIf+BUdZvVKiPIi1mOQBdcw=; b=WmTmsbNV4v7hZzr6TfI30MnfwxiIrVn9BMmYrgPIN241Sm+ELwH7OA/lyjtco4sj1d 2sHk/V3MrmSkJ/Qwb/3lnMltM/Tsyl+MNjmtdWqN8ShX1NKmoMZ0G7IH7U6JQPNKVgaZ sWMt+4rfovPntGPM4eyAeAUOme/xXWa4nKV76T7SmkKsoH3HU4GAH8x3cr7sUJ3MfaGS tCjUO6qmwtjnaXzSAHTo9ZTBEPdm7LtS93akyCiqKI8F7vDhNmTkypFeBObPk7G6PiPF iFfem4I2spoPmTufzqYoXzr4Fcf5eEFN/cGIGRC2x4wDMkFc7G9Qg9dl0wlobNaZRz2M e5SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694009836; x=1694614636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sw98O3dNVCOWfHSc7YY7jIf+BUdZvVKiPIi1mOQBdcw=; b=DyGNm4nvC8PuuKFhn0sv3eLL5vSm3y72R2HNS4L114ymv8/IHx1yeHvXHjwrdwpoEQ rGe8EHDVnI1669iiqTIId7MbpQ+7kV+AXjP+oRbGcCf0h1yUJvH0MUSXVQVtQgqevYJJ H0zJrqsUUdol/8N1+zC2IC2u4so7xAHIimZyPWtwHZGGzu3JnzRu7Y9gb0kXvwFwdXf4 5+FpQL3sp5Dg/TqqEXVcn87+o6gmDocXzk9AjISJ0ENHd3ChdYQ6CkPMMMeDzREeVKDX qvMuHdiy0IB0A7aLLgM720uo0eB5E/pud24kLiSxhLO7tvkU5iOa2qfXdA3X/Dk381hp lyHQ== X-Gm-Message-State: AOJu0YxabhNpPwJGmnprdtWjqIQo/Yy13mbnNb7eCG2Z2CU2QP52zWbT lEST4JaAyaI7k64zfbU+NYk= X-Google-Smtp-Source: AGHT+IGSIbhKzrOjWCvms+7Z61U1tEoTGzaXlQq2EBYHaEtHxzuSDu51EF1+1sEkkrV/ZXGS9GMiDw== X-Received: by 2002:a05:600c:1da5:b0:3fe:d46a:ef4b with SMTP id p37-20020a05600c1da500b003fed46aef4bmr12740760wms.1.1694009835943; Wed, 06 Sep 2023 07:17:15 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id z12-20020adff1cc000000b0031ddf6cc89csm20437091wro.98.2023.09.06.07.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 07:17:15 -0700 (PDT) From: Simon Tournier Date: Wed, 6 Sep 2023 16:17:08 +0200 Message-Id: <32d3fb5066e0b20e200dabef0fba897634e21dda.1694009405.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <86ledjoaly.fsf@gmail.com> References: <86ledjoaly.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 Follow-up of 756e336fa008c2469b4a7317ad5c641ed48f25d6 fixing the issue. * guix/git/scm (reference-available?): Address case by case to determine whether the reference exists in the local Git checkout. --- guix/git.scm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) Hi, Here a draft about what I think is the correct solution. Well, the tests we have talked about are all passing. Let me know what you think. Cheers, simon base-commit: 6113e0529d61df7425f64e30a6bf77f7cfdfe5a5 diff --git a/guix/git.scm b/guix/git.scm index 1cb87a45607b..1b3355109e42 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 Marius Bakke ;;; Copyright © 2022 Maxime Devos ;;; Copyright © 2023 Tobias Geerinckx-Rice +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -360,21 +361,16 @@ (define-syntax-rule (false-if-git-not-found exp) (define (reference-available? repository ref) "Return true if REF, a reference such as '(commit . \"cabba9e\"), is definitely available in REPOSITORY, false otherwise." - ;; Note: this must not rely on 'resolve-reference', as that procedure always - ;; resolves the references for branch names such as master. The semantic we - ;; want here is that unless the reference is exact (e.g. a commit), the - ;; reference should not be considered available, as it could have changed on - ;; the remote. (match ref - ((or ('commit . commit) - ('tag-or-commit . (? commit-id? commit))) - (let ((len (string-length commit)) - (oid (string->oid commit))) - (false-if-git-not-found - (->bool (if (< len 40) - (object-lookup-prefix repository oid len OBJ-COMMIT) - (commit-lookup repository oid)))))) + (('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)))) (_ + ;; For the others REF as branch or symref, the REF cannot be available #f))) (define (clone-from-swh url tag-or-commit output)