GNU bug report logs - #78034
[PATCH] guix: transformations: git source transformations honour RECURSIVE?.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Romain GARBAGE <romain.garbage@HIDDEN>; Keywords: patch; Done: Ludovic Courtès <ludovic.courtes@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 78034-done <at> debbugs.gnu.org:


Received: (at 78034-done) by debbugs.gnu.org; 5 May 2025 15:35:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 05 11:35:09 2025
Received: from localhost ([127.0.0.1]:41775 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uBxqX-0005p6-48
	for submit <at> debbugs.gnu.org; Mon, 05 May 2025 11:35:09 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59610)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1uBxqO-0005jZ-60
 for 78034-done <at> debbugs.gnu.org; Mon, 05 May 2025 11:35:00 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1uBxqH-0001qk-6J; Mon, 05 May 2025 11:34:53 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludovic.courtes@HIDDEN>
To: Romain GARBAGE <romain.garbage@HIDDEN>
Subject: Re: bug#78034: [PATCH] guix: transformations: git source
 transformations honour RECURSIVE?.
In-Reply-To: <a699d333724eb9d2dcba7f1e2e3f301db5f0a2c0.1745569940.git.romain.garbage@HIDDEN>
 (Romain GARBAGE's message of "Fri, 25 Apr 2025 10:32:20 +0200")
References: <8306eb0b4d96b233e62d87f13444f9c55354b34c.1745502758.git.romain.garbage@HIDDEN>
 <a699d333724eb9d2dcba7f1e2e3f301db5f0a2c0.1745569940.git.romain.garbage@HIDDEN>
Date: Mon, 05 May 2025 14:42:46 +0200
Message-ID: <87ecx35iux.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78034-done
Cc: Josselin Poiret <dev@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Tobias Geerinckx-Rice <me@HIDDEN>, ludovic.courtes@HIDDEN,
 Christopher Baines <guix@HIDDEN>, 78034-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Romain GARBAGE <romain.garbage@HIDDEN> writes:

> * guix/transformations.scm (package-git-url+recursive?): New variable.
> (package-git-url): Remove variable.
> (evaluate-git-replacement-specs): Use package-git-url+recursive?.
> (transform-package-source-branch, transform-package-source-commit, transform-package-source-git-url): Update
> according to changes above.
> * doc/guix.texi (Package Transformation Options): Update documentation.
> * tests/transformations.scm: Update tests. Add tests for RECURSIVE?
> inheritance with WITH-COMMIT and WITH-SOURCE.
>
> Change-Id: Id6a5e6957a9955c8173b06b3e14f2986c6dfc4bc

Pushed as 79bc4ebb332d30c31913164b18105c6d8e637c7a, thanks!




Notification sent to Romain GARBAGE <romain.garbage@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Ludovic Courtès <ludovic.courtes@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 78034 <at> debbugs.gnu.org:


Received: (at 78034) by debbugs.gnu.org; 25 Apr 2025 08:34:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 25 04:34:50 2025
Received: from localhost ([127.0.0.1]:46973 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8EWH-0004oe-Qr
	for submit <at> debbugs.gnu.org; Fri, 25 Apr 2025 04:34:50 -0400
Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:43857)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <romain.garbage@HIDDEN>)
 id 1u8EWF-0004oM-DA
 for 78034 <at> debbugs.gnu.org; Fri, 25 Apr 2025 04:34:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc;
 h=from:to:cc:subject:in-reply-to:references:date:
 message-id:mime-version:content-transfer-encoding;
 bh=twVOq3S0KfZlWzJ9uNHSYnoLguIUOQUy6We1pe3AWdI=;
 b=l3q7V/BO/v0jMYyB6Tk7N+GkXuSDkk8LbhhlwBJFMuGwvIVOuoHB/D3H
 vGAY4XYW1bsE9Nw5/1cGCBvAzdH8KH9g+lZ4c4DDU/E0HGOri+9iyqrhg
 lAue2FjhCdN1Ex37qV25SinjCGHmU55ShrnrjTg2NoROimKq/yNWLnZey 0=;
Authentication-Results: mail2-relais-roc.national.inria.fr;
 dkim=none (message not signed) header.i=none;
 spf=SoftFail smtp.mailfrom=romain.garbage@HIDDEN;
 dmarc=fail (p=none dis=none) d=inria.fr
X-IronPort-AV: E=Sophos;i="6.15,238,1739833200"; d="scan'208";a="219405455"
Received: from unknown (HELO localhost) ([193.50.110.224])
 by mail2-relais-roc.national.inria.fr with
 ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2025 10:34:41 +0200
From: Romain Garbage <romain.garbage@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludovic.courtes@HIDDEN>
Subject: Re: [bug#78034] [PATCH] guix: transformations: git source
 transformations honour RECURSIVE?.
In-Reply-To: <87zfg5k4sg.fsf@HIDDEN> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?=
 =?utf-8?Q?s?= message of "Thu, 24 Apr 2025 16:33:35 +0200")
References: <8306eb0b4d96b233e62d87f13444f9c55354b34c.1745502758.git.romain.garbage@HIDDEN>
 <87zfg5k4sg.fsf@HIDDEN>
User-Agent: mu4e 1.12.9; emacs 29.4
Date: Fri, 25 Apr 2025 10:34:39 +0200
Message-ID: <87h62cvduo.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78034
Cc: Josselin Poiret <dev@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, 78034 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>,
 Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Ludovic Court=C3=A8s <ludovic.courtes@HIDDEN> writes:

> Hello!

Hi Ludo'

> Overall LGTM!  Minor suggestions:
>
> Romain GARBAGE <romain.garbage@HIDDEN> writes:
>
>> +                      ;; Try to propagate RECURSIVE? from the package s=
ource when it
>> +                      ;; is a git-checkout or a git-reference, keeping =
TRUE as
>> +                      ;; default in other cases.
>> +                      (let ((url recursive? (guard (c ((formatted-messa=
ge? c )
>> +                                                       (values url #t)))
>> +                                              (package-git-url+recursiv=
e? old))))
>
> Instead of catching =E2=80=98formatted-message?=E2=80=99, I would rather =
add an =E2=80=98if=E2=80=99 for
> origin + git-reference or git-checkout.

Done in v2.

>> --- a/tests/transformations.scm
>> +++ b/tests/transformations.scm
>> @@ -217,8 +217,7 @@ (define-module (test-transformations)
>>=20=20
>>  (test-equal "options->transformation, with-branch"
>>    (git-checkout (url "https://example.org")
>> -                (branch "devel")
>> -                (recursive? #t))
>> +                (branch "devel"))
>
> IWBN to add a test where (recursive? #t) is inherited.

Done in v2: I added 2 tests, one form WITH-COMMIT and one for
WITH-BRANCH.

Romain




Information forwarded to guix-patches@HIDDEN:
bug#78034; Package guix-patches. Full text available.

Message received at 78034 <at> debbugs.gnu.org:


Received: (at 78034) by debbugs.gnu.org; 25 Apr 2025 08:32:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 25 04:32:53 2025
Received: from localhost ([127.0.0.1]:46955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u8EUO-0004jQ-G3
	for submit <at> debbugs.gnu.org; Fri, 25 Apr 2025 04:32:53 -0400
Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:43705)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <romain.garbage@HIDDEN>)
 id 1u8EUK-0004iv-69
 for 78034 <at> debbugs.gnu.org; Fri, 25 Apr 2025 04:32:50 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc;
 h=from:to:cc:subject:date:message-id:mime-version:
 content-transfer-encoding;
 bh=mpRFqT7VWGBEgFEotVJkIpS8thM28ajsbzgU+Ut+v1U=;
 b=FKeo6PPTiD+ZwU+YkEHSBPvpDE7eKQ5V+M2AqB3u7ONQgFwPGNayyQTt
 iSQXRbSRN+T3pGby3AyWsk+iVl99+P/ARlO7VmXrfWfsI8ENwYoalmdGU
 wQrifrEDCqSbv2AgxQKePpTmDIIyc8CMhojEqN/bJ7jXOT4TWjcha/kLV s=;
Authentication-Results: mail2-relais-roc.national.inria.fr;
 dkim=none (message not signed) header.i=none;
 spf=SoftFail smtp.mailfrom=romain.garbage@HIDDEN;
 dmarc=fail (p=none dis=none) d=inria.fr
X-IronPort-AV: E=Sophos;i="6.15,238,1739833200"; d="scan'208";a="219405017"
Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.224])
 by mail2-relais-roc.national.inria.fr with
 ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2025 10:32:41 +0200
From: Romain GARBAGE <romain.garbage@HIDDEN>
To: 78034 <at> debbugs.gnu.org
Subject: [PATCH v2] guix: transformations: git source transformations honour
 RECURSIVE?.
Date: Fri, 25 Apr 2025 10:32:20 +0200
Message-ID: <a699d333724eb9d2dcba7f1e2e3f301db5f0a2c0.1745569940.git.romain.garbage@HIDDEN>
X-Mailer: git-send-email 2.49.0
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78034
Cc: ludovic.courtes@HIDDEN, Romain GARBAGE <romain.garbage@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

* guix/transformations.scm (package-git-url+recursive?): New variable.
(package-git-url): Remove variable.
(evaluate-git-replacement-specs): Use package-git-url+recursive?.
(transform-package-source-branch, transform-package-source-commit, transform-package-source-git-url): Update
according to changes above.
* doc/guix.texi (Package Transformation Options): Update documentation.
* tests/transformations.scm: Update tests. Add tests for RECURSIVE?
inheritance with WITH-COMMIT and WITH-SOURCE.

Change-Id: Id6a5e6957a9955c8173b06b3e14f2986c6dfc4bc
---
 doc/guix.texi             |  8 +++---
 guix/transformations.scm  | 53 ++++++++++++++++++++++++++-------------
 tests/transformations.scm | 52 +++++++++++++++++++++++++++++++++++---
 3 files changed, 89 insertions(+), 24 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 32ef844f5c..3d5a1238a6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13584,9 +13584,11 @@ Package Transformation Options
 @item --with-git-url=@var{package}=@var{url}
 @cindex Git, using the latest commit
 @cindex latest commit, building
-Build @var{package} from the latest commit of the @code{master} branch of the
-Git repository at @var{url}.  Git sub-modules of the repository are fetched,
-recursively.
+Build @var{package} from the latest commit of the @code{master} branch
+of the Git repository at @var{url}.  Git sub-modules of the repository
+are fetched, recursively, if @var{package} @code{source} is not a Git
+repository, otherwise it depends on the inherited value of
+@code{recursive?}.
 
 For example, the following command builds the NumPy Python library against the
 latest commit of the master branch of Python itself:
diff --git a/guix/transformations.scm b/guix/transformations.scm
index 2887d91a34..19a1cba206 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -29,8 +29,13 @@ (define-module (guix transformations)
   #:use-module (guix profiles)
   #:use-module (guix diagnostics)
   #:autoload   (guix download) (download-to-store)
-  #:autoload   (guix git-download) (git-reference? git-reference-url)
-  #:autoload   (guix git) (git-checkout git-checkout? git-checkout-url)
+  #:autoload   (guix git-download) (git-reference?
+                                    git-reference-url
+                                    git-reference-recursive?)
+  #:autoload   (guix git) (git-checkout
+                           git-checkout?
+                           git-checkout-url
+                           git-checkout-recursive?)
   #:autoload   (guix upstream) (upstream-source
                                 package-latest-release
                                 preferred-upstream-source
@@ -234,15 +239,18 @@ (define (transform-package-inputs/graft replacement-specs)
 (define %not-equal
   (char-set-complement (char-set #\=)))
 
-(define (package-git-url package)
-  "Return the URL of the Git repository for package, or raise an error if
-the source of PACKAGE is not fetched from a Git repository."
+(define (package-git-url+recursive? package)
+  "Return two values: the URL of the Git repository for package and a boolean
+indicating if the repository has to be recursively cloned, or raise an error if the
+source of PACKAGE is not fetched from a Git repository."
   (let ((source (package-source package)))
     (cond ((and (origin? source)
                 (git-reference? (origin-uri source)))
-           (git-reference-url (origin-uri source)))
+           (values (git-reference-url (origin-uri source))
+                   (git-reference-recursive? (origin-uri source))))
           ((git-checkout? source)
-           (git-checkout-url source))
+           (values (git-checkout-url source)
+                   (git-checkout-recursive? source)))
           (else
            (raise
             (formatted-message (G_ "the source of ~a is not a Git reference")
@@ -257,9 +265,9 @@ (define (evaluate-git-replacement-specs specs proc)
          (match (string-tokenize spec %not-equal)
            ((spec branch-or-commit)
             (define (replace old)
-              (let* ((source (package-source old))
-                     (url    (package-git-url old)))
-                (proc old url branch-or-commit)))
+              (let* ((source         (package-source old))
+                     (url recursive? (package-git-url+recursive? old)))
+                (proc old url branch-or-commit recursive?)))
 
             (cons spec replace))
            (_
@@ -273,7 +281,7 @@ (define (transform-package-source-branch replacement-specs)
 dependencies according to REPLACEMENT-SPECS.  REPLACEMENT-SPECS is a list of
 strings like \"guile-next=stable-3.0\" meaning that packages are built using
 'guile-next' from the latest commit on its 'stable-3.0' branch."
-  (define (replace old url branch)
+  (define (replace old url branch recursive?)
     (package
       (inherit old)
       (version (string-append "git." (string-map (match-lambda
@@ -281,7 +289,7 @@ (define (transform-package-source-branch replacement-specs)
                                                    (chr chr))
                                                  branch)))
       (source (git-checkout (url url) (branch branch)
-                            (recursive? #t)))))
+                            (recursive? recursive?)))))
 
   (let* ((replacements (evaluate-git-replacement-specs replacement-specs
                                                        replace))
@@ -315,12 +323,12 @@ (define (transform-package-source-commit replacement-specs)
 dependencies according to REPLACEMENT-SPECS.  REPLACEMENT-SPECS is a list of
 strings like \"guile-next=cabba9e\" meaning that packages are built using
 'guile-next' from commit 'cabba9e'."
-  (define (replace old url commit)
+  (define (replace old url commit recursive?)
     (package
       (inherit old)
       (version (commit->version-string commit))
       (source (git-checkout (url url) (commit commit)
-                            (recursive? #t)))))
+                            (recursive? recursive?)))))
 
   (let* ((replacements (evaluate-git-replacement-specs replacement-specs
                                                        replace))
@@ -341,10 +349,19 @@ (define (transform-package-source-git-url replacement-specs)
              ((spec url)
               (cons spec
                     (lambda (old)
-                      (package
-                        (inherit old)
-                        (source (git-checkout (url url)
-                                              (recursive? #t)))))))
+                      ;; Propagate RECURSIVE? from the package source when it is a
+                      ;; git-checkout or a git-reference, keeping TRUE as default in
+                      ;; other cases.
+                      (let* ((uri (and (origin? (package-source old))
+                                       (origin-uri (package-source old))))
+                             (recursive? (if (or (git-checkout? uri)
+                                                 (git-reference? uri))
+                                             (package-git-url+recursive? old)
+                                             #t)))
+                        (package
+                          (inherit old)
+                          (source (git-checkout (url url)
+                                                (recursive? recursive?))))))))
              (_
               (raise
                (formatted-message
diff --git a/tests/transformations.scm b/tests/transformations.scm
index 5285d98f17..9f5aacc41b 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -217,8 +217,7 @@ (define-module (test-transformations)
 
 (test-equal "options->transformation, with-branch"
   (git-checkout (url "https://example.org")
-                (branch "devel")
-                (recursive? #t))
+                (branch "devel"))
   (let* ((p (dummy-package "guix.scm"
               (inputs `(("foo" ,grep)
                         ("bar" ,(dummy-package "chbouib"
@@ -238,7 +237,53 @@ (define-module (test-transformations)
                    (string=? (package-name dep2) "chbouib")
                    (package-source dep2))))))))
 
+(test-equal "options->transformation, with-branch, recursive? inheritance"
+  (git-checkout (url "https://example.org")
+                (branch "devel")
+                (recursive? #t))
+  (let* ((p (dummy-package "guix.scm"
+              (inputs `(("foo" ,grep)
+                        ("bar" ,(dummy-package "chbouib"
+                                  (source (origin
+                                            (method git-fetch)
+                                            (uri (git-reference
+                                                  (url "https://example.org")
+                                                  (commit "cabba9e")
+                                                  (recursive? #t)))
+                                            (sha256 #f)))))))))
+         (t (options->transformation '((with-branch . "chbouib=devel")))))
+    (let ((new (t p)))
+      (and (not (eq? new p))
+           (match (package-inputs new)
+             ((("foo" dep1) ("bar" dep2))
+              (and (string=? (package-full-name dep1)
+                             (package-full-name grep))
+                   (string=? (package-name dep2) "chbouib")
+                   (package-source dep2))))))))
+
 (test-equal "options->transformation, with-commit"
+  (git-checkout (url "https://example.org")
+                (commit "abcdef"))
+  (let* ((p (dummy-package "guix.scm"
+              (inputs `(("foo" ,grep)
+                        ("bar" ,(dummy-package "chbouib"
+                                  (source (origin
+                                            (method git-fetch)
+                                            (uri (git-reference
+                                                  (url "https://example.org")
+                                                  (commit "cabba9e")))
+                                            (sha256 #f)))))))))
+         (t (options->transformation '((with-commit . "chbouib=abcdef")))))
+    (let ((new (t p)))
+      (and (not (eq? new p))
+           (match (package-inputs new)
+             ((("foo" dep1) ("bar" dep2))
+              (and (string=? (package-full-name dep1)
+                             (package-full-name grep))
+                   (string=? (package-name dep2) "chbouib")
+                   (package-source dep2))))))))
+
+(test-equal "options->transformation, with-commit, recursive? inheritance"
   (git-checkout (url "https://example.org")
                 (commit "abcdef")
                 (recursive? #t))
@@ -249,7 +294,8 @@ (define-module (test-transformations)
                                             (method git-fetch)
                                             (uri (git-reference
                                                   (url "https://example.org")
-                                                  (commit "cabba9e")))
+                                                  (commit "cabba9e")
+                                                  (recursive? #t)))
                                             (sha256 #f)))))))))
          (t (options->transformation '((with-commit . "chbouib=abcdef")))))
     (let ((new (t p)))

base-commit: b12d44dd5e35ac236bf3fbb5619b9c8c2f42c902
-- 
2.49.0





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#78034; Package guix-patches. Full text available.

Message received at 78034 <at> debbugs.gnu.org:


Received: (at 78034) by debbugs.gnu.org; 24 Apr 2025 15:50:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 24 11:50:11 2025
Received: from localhost ([127.0.0.1]:40378 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u7yq2-000723-SB
	for submit <at> debbugs.gnu.org; Thu, 24 Apr 2025 11:50:11 -0400
Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:27176)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1u7ypz-000716-Ia
 for 78034 <at> debbugs.gnu.org; Thu, 24 Apr 2025 11:50:08 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc;
 h=from:to:cc:subject:in-reply-to:references:date:
 message-id:mime-version:content-transfer-encoding;
 bh=RLi5Kpe72Hn9T2VNg4dbL0nkgKxo0TQpF35+i+LWXdU=;
 b=j5CXXi7seMf9MSR2UVAJuqoyIP1UUmUIPHTkSEmvpSiiYcaQrU0Kaz2y
 pgcatyc79PZ+j5mZ0sR8xddCPF9EM1FmSzTnc7Xy2G/eM9iNXFysflBPg
 zvHeMShQRw3/NRRcj2dXNFPdcN1dnAqWGPGh3zb7BEVbshuDy6bTkh5J7 A=;
Authentication-Results: mail3-relais-sop.national.inria.fr;
 dkim=none (message not signed) header.i=none;
 spf=SoftFail smtp.mailfrom=ludo@HIDDEN;
 dmarc=fail (p=none dis=none) d=inria.fr
X-IronPort-AV: E=Sophos;i="6.15,236,1739833200"; d="scan'208";a="115104175"
Received: from unknown (HELO ribbon) ([193.50.110.57])
 by mail3-relais-sop.national.inria.fr with
 ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2025 17:50:00 +0200
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludovic.courtes@HIDDEN>
To: Romain GARBAGE <romain.garbage@HIDDEN>
Subject: Re: [bug#78034] [PATCH] guix: transformations: git source
 transformations honour RECURSIVE?.
In-Reply-To: <8306eb0b4d96b233e62d87f13444f9c55354b34c.1745502758.git.romain.garbage@HIDDEN>
 (Romain GARBAGE's message of "Thu, 24 Apr 2025 15:52:39 +0200")
References: <8306eb0b4d96b233e62d87f13444f9c55354b34c.1745502758.git.romain.garbage@HIDDEN>
Date: Thu, 24 Apr 2025 16:33:35 +0200
Message-ID: <87zfg5k4sg.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: 78034
Cc: Josselin Poiret <dev@HIDDEN>,
 Maxim Cournoyer <maxim.cournoyer@HIDDEN>,
 Simon Tournier <zimon.toutoune@HIDDEN>, 78034 <at> debbugs.gnu.org,
 Tobias Geerinckx-Rice <me@HIDDEN>, ludovic.courtes@HIDDEN,
 Mathieu Othacehe <othacehe@HIDDEN>, Christopher Baines <guix@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Hello!

Overall LGTM!  Minor suggestions:

Romain GARBAGE <romain.garbage@HIDDEN> writes:

> +                      ;; Try to propagate RECURSIVE? from the package so=
urce when it
> +                      ;; is a git-checkout or a git-reference, keeping T=
RUE as
> +                      ;; default in other cases.
> +                      (let ((url recursive? (guard (c ((formatted-messag=
e? c )
> +                                                       (values url #t)))
> +                                              (package-git-url+recursive=
? old))))

Instead of catching =E2=80=98formatted-message?=E2=80=99, I would rather ad=
d an =E2=80=98if=E2=80=99 for
origin + git-reference or git-checkout.

> --- a/tests/transformations.scm
> +++ b/tests/transformations.scm
> @@ -217,8 +217,7 @@ (define-module (test-transformations)
>=20=20
>  (test-equal "options->transformation, with-branch"
>    (git-checkout (url "https://example.org")
> -                (branch "devel")
> -                (recursive? #t))
> +                (branch "devel"))

IWBN to add a test where (recursive? #t) is inherited.

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#78034; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Apr 2025 13:53:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 24 09:53:04 2025
Received: from localhost ([127.0.0.1]:37479 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u7x0h-0007WT-Fv
	for submit <at> debbugs.gnu.org; Thu, 24 Apr 2025 09:53:04 -0400
Received: from lists.gnu.org ([2001:470:142::17]:38998)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <romain.garbage@HIDDEN>)
 id 1u7x0e-0007Vw-N2
 for submit <at> debbugs.gnu.org; Thu, 24 Apr 2025 09:53:01 -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 <romain.garbage@HIDDEN>)
 id 1u7x0Z-0001Wv-9X
 for guix-patches@HIDDEN; Thu, 24 Apr 2025 09:52:55 -0400
Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <romain.garbage@HIDDEN>)
 id 1u7x0X-0006dA-0q
 for guix-patches@HIDDEN; Thu, 24 Apr 2025 09:52:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc;
 h=from:to:cc:subject:date:message-id:mime-version:
 content-transfer-encoding;
 bh=VvWEaVpIp8eqbTxZJEo8fIDsp8j+0Y3/7hCzzrt5Vtk=;
 b=PlyMWRnriJMAb8/L/3DOxcixZOE0KNVHU2myGOL3OeKeLGwfjqle8KD1
 bffHV6mGcrNSIvvcEx3gy8ArpMv4U9WkSNQQYn0rxEeM6kr9uoQ0soXBG
 GzJdObGnYCjB7dd3+2FzXSjybMTlIbrocl7Wk44/ZXCCwVHzXi9/sGMOy 4=;
Authentication-Results: mail2-relais-roc.national.inria.fr;
 dkim=none (message not signed) header.i=none;
 spf=SoftFail smtp.mailfrom=romain.garbage@HIDDEN;
 dmarc=fail (p=none dis=none) d=inria.fr
X-IronPort-AV: E=Sophos;i="6.15,236,1739833200"; d="scan'208";a="219302872"
Received: from unknown (HELO guix-A102.bordeaux.inria.fr) ([193.50.110.224])
 by mail2-relais-roc.national.inria.fr with
 ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2025 15:52:51 +0200
From: Romain GARBAGE <romain.garbage@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] guix: transformations: git source transformations honour
 RECURSIVE?.
Date: Thu, 24 Apr 2025 15:52:39 +0200
Message-ID: <8306eb0b4d96b233e62d87f13444f9c55354b34c.1745502758.git.romain.garbage@HIDDEN>
X-Mailer: git-send-email 2.49.0
MIME-Version: 1.0
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Maxim Cournoyer <maxim.cournoyer@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=192.134.164.83;
 envelope-from=romain.garbage@HIDDEN; helo=mail2-relais-roc.national.inria.fr
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
Cc: ludovic.courtes@HIDDEN, Romain GARBAGE <romain.garbage@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/transformations.scm (package-git-url+recursive?): New variable.
(package-git-url): Remove variable.
(evaluate-git-replacement-specs): Use package-git-url+recursive?.
(transform-package-source-branch, transform-package-source-commit, transform-package-source-git-url): Update
according to changes above.
* doc/guix.texi (Package Transformation Options): Update documentation.
* tests/transformations.scm: Update tests.

Change-Id: Id6a5e6957a9955c8173b06b3e14f2986c6dfc4bc
---
 doc/guix.texi             |  8 ++++---
 guix/transformations.scm  | 50 +++++++++++++++++++++++++--------------
 tests/transformations.scm |  6 ++---
 3 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 32ef844f5c..3d5a1238a6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -13584,9 +13584,11 @@ Package Transformation Options
 @item --with-git-url=@var{package}=@var{url}
 @cindex Git, using the latest commit
 @cindex latest commit, building
-Build @var{package} from the latest commit of the @code{master} branch of the
-Git repository at @var{url}.  Git sub-modules of the repository are fetched,
-recursively.
+Build @var{package} from the latest commit of the @code{master} branch
+of the Git repository at @var{url}.  Git sub-modules of the repository
+are fetched, recursively, if @var{package} @code{source} is not a Git
+repository, otherwise it depends on the inherited value of
+@code{recursive?}.
 
 For example, the following command builds the NumPy Python library against the
 latest commit of the master branch of Python itself:
diff --git a/guix/transformations.scm b/guix/transformations.scm
index 2887d91a34..7715373c43 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -29,8 +29,13 @@ (define-module (guix transformations)
   #:use-module (guix profiles)
   #:use-module (guix diagnostics)
   #:autoload   (guix download) (download-to-store)
-  #:autoload   (guix git-download) (git-reference? git-reference-url)
-  #:autoload   (guix git) (git-checkout git-checkout? git-checkout-url)
+  #:autoload   (guix git-download) (git-reference?
+                                    git-reference-url
+                                    git-reference-recursive?)
+  #:autoload   (guix git) (git-checkout
+                           git-checkout?
+                           git-checkout-url
+                           git-checkout-recursive?)
   #:autoload   (guix upstream) (upstream-source
                                 package-latest-release
                                 preferred-upstream-source
@@ -234,15 +239,18 @@ (define (transform-package-inputs/graft replacement-specs)
 (define %not-equal
   (char-set-complement (char-set #\=)))
 
-(define (package-git-url package)
-  "Return the URL of the Git repository for package, or raise an error if
-the source of PACKAGE is not fetched from a Git repository."
+(define (package-git-url+recursive? package)
+  "Return two values: the URL of the Git repository for package and a boolean
+indicating if the repository has to be recursively cloned, or raise an error if the
+source of PACKAGE is not fetched from a Git repository."
   (let ((source (package-source package)))
     (cond ((and (origin? source)
                 (git-reference? (origin-uri source)))
-           (git-reference-url (origin-uri source)))
+           (values (git-reference-url (origin-uri source))
+                   (git-reference-recursive? (origin-uri source))))
           ((git-checkout? source)
-           (git-checkout-url source))
+           (values (git-checkout-url source)
+                   (git-checkout-recursive? source)))
           (else
            (raise
             (formatted-message (G_ "the source of ~a is not a Git reference")
@@ -257,9 +265,9 @@ (define (evaluate-git-replacement-specs specs proc)
          (match (string-tokenize spec %not-equal)
            ((spec branch-or-commit)
             (define (replace old)
-              (let* ((source (package-source old))
-                     (url    (package-git-url old)))
-                (proc old url branch-or-commit)))
+              (let* ((source         (package-source old))
+                     (url recursive? (package-git-url+recursive? old)))
+                (proc old url branch-or-commit recursive?)))
 
             (cons spec replace))
            (_
@@ -273,7 +281,7 @@ (define (transform-package-source-branch replacement-specs)
 dependencies according to REPLACEMENT-SPECS.  REPLACEMENT-SPECS is a list of
 strings like \"guile-next=stable-3.0\" meaning that packages are built using
 'guile-next' from the latest commit on its 'stable-3.0' branch."
-  (define (replace old url branch)
+  (define (replace old url branch recursive?)
     (package
       (inherit old)
       (version (string-append "git." (string-map (match-lambda
@@ -281,7 +289,7 @@ (define (transform-package-source-branch replacement-specs)
                                                    (chr chr))
                                                  branch)))
       (source (git-checkout (url url) (branch branch)
-                            (recursive? #t)))))
+                            (recursive? recursive?)))))
 
   (let* ((replacements (evaluate-git-replacement-specs replacement-specs
                                                        replace))
@@ -315,12 +323,12 @@ (define (transform-package-source-commit replacement-specs)
 dependencies according to REPLACEMENT-SPECS.  REPLACEMENT-SPECS is a list of
 strings like \"guile-next=cabba9e\" meaning that packages are built using
 'guile-next' from commit 'cabba9e'."
-  (define (replace old url commit)
+  (define (replace old url commit recursive?)
     (package
       (inherit old)
       (version (commit->version-string commit))
       (source (git-checkout (url url) (commit commit)
-                            (recursive? #t)))))
+                            (recursive? recursive?)))))
 
   (let* ((replacements (evaluate-git-replacement-specs replacement-specs
                                                        replace))
@@ -341,10 +349,16 @@ (define (transform-package-source-git-url replacement-specs)
              ((spec url)
               (cons spec
                     (lambda (old)
-                      (package
-                        (inherit old)
-                        (source (git-checkout (url url)
-                                              (recursive? #t)))))))
+                      ;; Try to propagate RECURSIVE? from the package source when it
+                      ;; is a git-checkout or a git-reference, keeping TRUE as
+                      ;; default in other cases.
+                      (let ((url recursive? (guard (c ((formatted-message? c )
+                                                       (values url #t)))
+                                              (package-git-url+recursive? old))))
+                        (package
+                          (inherit old)
+                          (source (git-checkout (url url)
+                                                (recursive? recursive?))))))))
              (_
               (raise
                (formatted-message
diff --git a/tests/transformations.scm b/tests/transformations.scm
index 5285d98f17..844dac43fc 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -217,8 +217,7 @@ (define-module (test-transformations)
 
 (test-equal "options->transformation, with-branch"
   (git-checkout (url "https://example.org")
-                (branch "devel")
-                (recursive? #t))
+                (branch "devel"))
   (let* ((p (dummy-package "guix.scm"
               (inputs `(("foo" ,grep)
                         ("bar" ,(dummy-package "chbouib"
@@ -240,8 +239,7 @@ (define-module (test-transformations)
 
 (test-equal "options->transformation, with-commit"
   (git-checkout (url "https://example.org")
-                (commit "abcdef")
-                (recursive? #t))
+                (commit "abcdef"))
   (let* ((p (dummy-package "guix.scm"
               (inputs `(("foo" ,grep)
                         ("bar" ,(dummy-package "chbouib"

base-commit: b12d44dd5e35ac236bf3fbb5619b9c8c2f42c902
-- 
2.49.0





Acknowledgement sent to Romain GARBAGE <romain.garbage@HIDDEN>:
New bug report received and forwarded. Copy sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, maxim.cournoyer@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#78034; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 5 May 2025 15:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.