~ruther/guix-local

6e12325bf31618abc76925a7239dfb51bdcab99b — Simon Tournier 8 months ago 052fab5
git: Fix update cached checkout when not a symref.

Follow up of 66463356ce5868d3551ea7014acb34543972a5d8.

* guix/git.scm (update-cached-checkout)[symref?]: New procedure.
[ref->refspecs]: New procedure.
Use them.

Change-Id: Ia2cb7db45222d59d61a2349bec277fd06456844b
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Modified-by: Ludovic Courtès <ludo@gnu.org>
1 files changed, 13 insertions(+), 9 deletions(-)

M guix/git.scm
M guix/git.scm => guix/git.scm +13 -9
@@ 5,7 5,7 @@
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
;;; Copyright © 2023 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2025 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;


@@ 575,10 575,16 @@ current settings unchanged."
                       (string-append "origin/" branch))))
      (_ ref)))

  (define symref-list
    (match ref
      (('symref . symref) (list symref))
      (_ '())))
  (define symref?
    (match-lambda
      (('symref . _) #t)
      (_ #f)))

  (define ref->refspecs
    (match-lambda
      (('symref . symref)
       (list (string-append "+" symref ":" symref)))
       (_ '())))

  (with-libgit2
   (set-git-timeouts connection-timeout read-timeout)


@@ 595,7 601,7 @@ current settings unchanged."

     ;; When using symrefs, fetch remote again even if it has been cloned just
     ;; before as the requested reference are not fetched when cloning.
     (when (and cache-exists?
     (when (and (or cache-exists? (symref? ref))
                (not (reference-available? repository ref)))
       (remote-fetch (remote-lookup repository "origin")
                     #:fetch-options (make-default-fetch-options


@@ 603,9 609,7 @@ current settings unchanged."
                                      verify-certificate?)
                     ;; Build refspecs from symbolic references so they are
                     ;; created locally and updated if necessary.
                     #:refspecs (map (lambda (ref)
                                       (string-append "+" ref ":" ref))
                                     symref-list)))
                     #:refspecs (ref->refspecs ref)))
     (when recursive?
       (update-submodules repository #:log-port log-port
                          #:fetch-options