From patchwork Wed Jul 15 23:18:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 23241 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 9598527BBE3; Thu, 16 Jul 2020 00:20:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 00F3527BBE1 for ; Thu, 16 Jul 2020 00:20:11 +0100 (BST) Received: from localhost ([::1]:57488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvqh8-0003vr-GL for patchwork@mira.cbaines.net; Wed, 15 Jul 2020 19:20:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jvqh0-0003ul-Vp for guix-patches@gnu.org; Wed, 15 Jul 2020 19:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jvqh0-000345-M2 for guix-patches@gnu.org; Wed, 15 Jul 2020 19:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jvqh0-0007IW-IH for guix-patches@gnu.org; Wed, 15 Jul 2020 19:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42381] [PATCH 2/3] git: 'update-cached-checkout' has a new #:check-out? parameter. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 15 Jul 2020 23:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42381 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42381@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 42381-submit@debbugs.gnu.org id=B42381.159485516527990 (code B ref 42381); Wed, 15 Jul 2020 23:20:02 +0000 Received: (at 42381) by debbugs.gnu.org; 15 Jul 2020 23:19:25 +0000 Received: from localhost ([127.0.0.1]:53986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jvqgP-0007HJ-Cr for submit@debbugs.gnu.org; Wed, 15 Jul 2020 19:19:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jvqgL-0007Gq-Qe for 42381@debbugs.gnu.org; Wed, 15 Jul 2020 19:19:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38494) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jvqgG-0002um-9K; Wed, 15 Jul 2020 19:19:16 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49700 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jvqgF-0002z2-Qk; Wed, 15 Jul 2020 19:19:16 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 16 Jul 2020 01:18:57 +0200 Message-Id: <20200715231858.10201-2-ludo@gnu.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200715231858.10201-1-ludo@gnu.org> References: <20200715231858.10201-1-ludo@gnu.org> 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" X-getmail-retrieved-from-mailbox: Patches * guix/git.scm (update-cached-checkout): Add #:check-out? parameter and honor it. --- guix/git.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index ca67b1d37c..7f8f9addfb 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -292,6 +292,7 @@ definitely available in REPOSITORY, false otherwise." #:key (ref '(branch . "master")) recursive? + (check-out? #t) starting-commit (log-port (%make-void-port "w")) (cache-directory @@ -306,7 +307,10 @@ provided) as returned by 'commit-relation'. REF is pair whose key is [branch | commit | tag | tag-or-commit ] and value the associated data: [ | | | ]. -When RECURSIVE? is true, check out submodules as well, if any." +When RECURSIVE? is true, check out submodules as well, if any. + +When CHECK-OUT? is true, reset the cached working tree to REF; otherwise leave +it unchanged." (define canonical-ref ;; We used to require callers to specify "origin/" for each branch, which ;; made little sense since the cache should be transparent to them. So @@ -337,7 +341,10 @@ When RECURSIVE? is true, check out submodules as well, if any." ;; Note: call 'commit-relation' from here because it's more efficient ;; than letting users re-open the checkout later on. - (let* ((oid (switch-to-ref repository canonical-ref)) + (let* ((oid (if check-out? + (switch-to-ref repository canonical-ref) + (object-id + (resolve-reference repository canonical-ref)))) (new (and starting-commit (commit-lookup repository oid))) (old (and starting-commit