git: Avoid touching the network unless needed in 'reference-available?'.
Follow-up of 756e336fa0
fixing the issue.
* guix/git/scm (reference-available?): Address case by case to determine
whether the reference exists in the local Git checkout.
This commit is contained in:
parent
f45c0c8228
commit
6d33c1f806
20
guix/git.scm
20
guix/git.scm
|
@ -5,6 +5,7 @@
|
||||||
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
|
;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
|
||||||
;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
|
;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
|
||||||
;;; Copyright © 2023 Tobias Geerinckx-Rice <me@tobias.gr>
|
;;; Copyright © 2023 Tobias Geerinckx-Rice <me@tobias.gr>
|
||||||
|
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -360,21 +361,16 @@ (define-syntax-rule (false-if-git-not-found exp)
|
||||||
(define (reference-available? repository ref)
|
(define (reference-available? repository ref)
|
||||||
"Return true if REF, a reference such as '(commit . \"cabba9e\"), is
|
"Return true if REF, a reference such as '(commit . \"cabba9e\"), is
|
||||||
definitely available in REPOSITORY, false otherwise."
|
definitely available in REPOSITORY, false otherwise."
|
||||||
;; Note: this must not rely on 'resolve-reference', as that procedure always
|
|
||||||
;; resolves the references for branch names such as master. The semantic we
|
|
||||||
;; want here is that unless the reference is exact (e.g. a commit), the
|
|
||||||
;; reference should not be considered available, as it could have changed on
|
|
||||||
;; the remote.
|
|
||||||
(match ref
|
(match ref
|
||||||
((or ('commit . commit)
|
(('commit . (? commit-id? commit))
|
||||||
('tag-or-commit . (? commit-id? commit)))
|
(let ((oid (string->oid commit)))
|
||||||
(let ((len (string-length commit))
|
(->bool (commit-lookup repository oid))))
|
||||||
(oid (string->oid commit)))
|
((or ('tag . str)
|
||||||
|
('tag-or-commit . str))
|
||||||
(false-if-git-not-found
|
(false-if-git-not-found
|
||||||
(->bool (if (< len 40)
|
(->bool (resolve-reference repository ref))))
|
||||||
(object-lookup-prefix repository oid len OBJ-COMMIT)
|
|
||||||
(commit-lookup repository oid))))))
|
|
||||||
(_
|
(_
|
||||||
|
;; For the others REF as branch or symref, the REF cannot be available
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
(define (clone-from-swh url tag-or-commit output)
|
(define (clone-from-swh url tag-or-commit output)
|
||||||
|
|
Loading…
Reference in a new issue