Subject: [bug#64746] [PATCH 2/2] scripts: time-machine: Error when attempting to visit too old commits.

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 22 Aug 2023 22:54:15 -0400

Hi again,

Simon Tournier <[email-masked]> writes:

> Re Maxim,
>
> On Thu, 17 Aug 2023 at 20:16, Maxim Cournoyer <[email-masked]> wrote:
>
>> > On Wed, 16 Aug 2023 at 14:47, Maxim Cournoyer <[email-masked]> wrote:
>> >
>> >>>>           (option '("commit") #t #f
>> >>>>                   (lambda (opt name arg result)
>> >>>> -                   (alist-cons 'ref `(commit . ,arg) result)))
>> >>>> +                   (alist-cons 'ref `(tag-or-commit . ,arg) result)))
>> >
>> > [...]
>> >
>> >>                       (match ref
>> >> -                       (('commit . commit)
>> >> +                       ((or ('commit . commit)
>> >> +                            ('tag-or-commit . commit))
>> >
>> >> The reason is to standardize the API of (guix pull) and (guix git),
>> >> whose procedure had a different expectation for 'ref' objects.
>> >
>> > My point is that this ’or’ is useless, IIUC.  Well, I have removed it in
>> > the series fixing the annoyance with the network access of “guix
>> > time-machine”.
>>
>> It isn't, unless you meant after applying further changes :-) You should
>> be able to see the problem by reverting that commit and running 'guix
>> time-machine --commit=v1.4.0 -- describe', for example.
>
> Yes for sure because you introduced this in guix/scripts/time-machine.scm,
>
>                   (lambda (opt name arg result)
> -                   (alist-cons 'ref `(commit . ,arg) result)))
> +                   (alist-cons 'ref `(tag-or-commit . ,arg) result)))
>
> with the previous commit 79ec651a286c71a3d4c72be33a1f80e76a560031.

It's a bit convoluted, but there are three things involved:

1. (guix scripts time-machine)
2. (guix pull)
3. (guix git)

They are involved in that order, if I remember correctly.

Now the important part is that the update-cached-checkout from (guix
git), newly used in (guix scripts time-machine), should be passed a
tag-or-commit ref and not a commit one if we want to support both tags
or commits (otherwise tags would throw an error about not respecting a
git hash format).

Since 'guix time-machine --commit' is documented as accepting a tag or
commit, it makes sense to tag it as such at that point.

I hope this clarifies it?

-- 
Thanks,
Maxim