[bug#78030,2/2] guix: git: Add support for symbolic references.

Message ID c3c3b27a70e7efe2db54c2ff488aa8e84b0d83f3.1745482799.git.romain.garbage@inria.fr
State New
Headers
Series Symref support in channels |

Commit Message

Romain GARBAGE April 24, 2025, 8:19 a.m. UTC
  * guix/git.scm (update-cached-checkout): Add support for symbolic references.

Change-Id: Ib7874e2a30f97e51fdfdc2231a3bc5a3b45a177d
---
 guix/git.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
  

Patch

diff --git a/guix/git.scm b/guix/git.scm
index 01e0918588..a6d921a8cf 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -563,7 +563,7 @@  (define* (update-cached-checkout url
 to REF, and the relation of STARTING-COMMIT relative to the new commit (if
 provided) as returned by 'commit-relation'.
 
-REF is pair whose key is [branch | commit | tag | tag-or-commit ] and value
+REF is pair whose key is [branch | commit | symref | tag | tag-or-commit ] and value
 the associated data: [<branch name> | <sha1> | <tag name> | <string>].
 If REF is the empty list, the remote HEAD is used.
 
@@ -599,6 +599,11 @@  (define* (update-cached-checkout url
                        (string-append "origin/" branch))))
       (_ ref)))
 
+  (define symref-list
+    (match ref
+      (('symref . symref) (list symref))
+      (_ '())))
+
   (with-libgit2
    (set-git-timeouts connection-timeout read-timeout)
    (let* ((cache-exists? (openable-repository? cache-directory))
@@ -613,7 +618,10 @@  (define* (update-cached-checkout url
        (remote-fetch (remote-lookup repository "origin")
                      #:fetch-options (make-default-fetch-options
                                       #:verify-certificate?
-                                      verify-certificate?)))
+                                      verify-certificate?)
+                     ;; Symbolic references are not fetched from the remote by
+                     ;; default.
+                     #:refspecs symref-list))
      (when recursive?
        (update-submodules repository #:log-port log-port
                           #:fetch-options