Subject: Re: bug#65352: Fix time-machine and network

From: Ludovic Courtès <[email-masked]>
Date: Mon, 04 Sep 2023 10:49:24 +0200

Hi,

Simon Tournier <[email-masked]> skribis:

> * guix/git/scm (reference-available?): Rely of the procedure resolve-reference
> to determine if the reference belongs to the local Git checkout.
> ---
>  guix/git.scm | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/guix/git.scm b/guix/git.scm
> index dbc3b7caa7..ebe2600209 100644
> --- a/guix/git.scm
> +++ b/guix/git.scm
> @@ -360,17 +360,8 @@ (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."
> -  (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))))))
> -    (_
> -     #f)))
> +  (false-if-git-not-found
> +   (->bool (resolve-reference repository ref))))

Houston, we have a problem:

--8<---------------cut here---------------start------------->8---
$ guix time-machine -C <(echo %default-channels) -- describe
Backtrace:
          17 (primitive-load "/home/ludo/.config/guix/current/bin/gu…")
In guix/ui.scm:
   2323:7 16 (run-guix . _)
  2286:10 15 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10 14 (with-exception-handler _ _ #:unwind? _ # _)
  1747:15 13 (with-exception-handler #<procedure 7f987de73fc0 at ic…> …)
In guix/store.scm:
    672:3 12 (_)
In ice-9/boot-9.scm:
  1752:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In guix/store.scm:
   659:37 10 (thunk)
In guix/status.scm:
    839:4  9 (call-with-status-report _ _)
In guix/store.scm:
   1298:8  8 (call-with-build-handler #<procedure 7f987de84420 at g…> …)
In guix/inferior.scm:
   932:10  7 (cached-channel-instance #<store-connection 256.99 7f9…> …)
In guix/scripts/time-machine.scm:
   171:42  6 (validate-guix-channel _)
In guix/git.scm:
   471:21  5 (update-cached-checkout _ #:ref _ #:recursive? _ # _ # _ …)
In ice-9/boot-9.scm:
  1747:15  4 (with-exception-handler #<procedure 7f987de900c0 at ic…> …)
In guix/git.scm:
   364:11  3 (_)
    235:4  2 (resolve _)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" ())'.
$ guix describe
Generation 272  Sep 03 2023 23:46:47    (current)
  guix e365c26
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: e365c26a34fa485f9af46538fcea128db681c33d
--8<---------------cut here---------------end--------------->8---

I’m testing the fix below:

diff --git a/guix/git.scm b/guix/git.scm
index ebe2600209..5fa604f9a0 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <[email-masked]>
-;;; Copyright © 2018-2022 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2018-2023 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2021 Kyle Meyer <[email-masked]>
 ;;; Copyright © 2021 Marius Bakke <[email-masked]>
 ;;; Copyright © 2022 Maxime Devos <[email-masked]>
@@ -282,7 +282,10 @@ (define (resolve-reference repository ref)
          (if (= OBJ-TAG (object-type obj))
              (object-lookup repository
                             (tag-target-id (tag-lookup repository oid)))
-             obj))))))
+             obj)))
+      (()
+       (resolve-reference repository
+                          '(symref . "refs/remotes/origin/HEAD"))))))
 
 (define (switch-to-ref repository ref)
   "Switch to REPOSITORY's branch, commit or tag specified by REF.  Return the

Ludo’.