Subject: [bug#65352] Fix time-machine and network

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 05 Sep 2023 16:39:28 -0400

Hi,

Ludovic Courtès <[email-masked]> writes:

> Hi again,
>
> 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))))
>>  
>>  (define (clone-from-swh url tag-or-commit output)
>>    "Attempt to clone TAG-OR-COMMIT (a string), which originates from URL, using
>>
>> base-commit: 1b2d43fe016848ea2ec16ff18cbc14340944fc4e
>
> In fact, now I recall why that procedure was written that way: it’s
> meant to say whether a given commit (and only a commit) is already in
> the checkout, meaning we don’t need to pull.  By definition, it’s an
> answer that can only be given for a specific commit; we cannot tell
> whether “master” or “HEAD” is available, that wouldn’t make sense.
>
> Thus, I think we need to revert
> a789dd58656d5f7f1b8edf790d77753fc71670af, and probably add a comment
> explaining why it’s written this way.
>
> Thoughts?

I've reviewed this thread and the code, and I agree.  This is a special
case.  I've added a comment so we aren't tempted to use
'resolve-reference' there again.

Will install shortly.

-- 
Thanks,
Maxim