diff --git a/guix/git.scm b/guix/git.scm index a5103547d3..449011c51a 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -32,6 +32,7 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix sets) + #:autoload (guix swh) (swh-download) #:use-module ((guix diagnostics) #:select (leave)) #:use-module (guix progress) #:use-module (rnrs bytevectors) @@ -459,22 +460,43 @@ Log progress and checkout info to LOG-PORT." (eq? 'regular (stat:type stat)))))) (format log-port "updating checkout of '~a'...~%" url) - (let*-values - (((checkout commit _) - (update-cached-checkout url - #:recursive? recursive? - #:ref ref - #:cache-directory - (url-cache-directory url cache-directory - #:recursive? - recursive?) - #:log-port log-port)) - ((name) - (url+commit->name url commit))) - (format log-port "retrieved commit ~a~%" commit) - (values (add-to-store store name #t "sha256" checkout - #:select? (negate dot-git?)) - commit))) + + (catch 'git-error + (lambda () + (let*-values + (((checkout commit _) + (update-cached-checkout (pk 'l-r-c url) + #:recursive? recursive? + #:ref ref + #:cache-directory + (url-cache-directory url cache-directory + #:recursive? + recursive?) + #:log-port log-port)) + ((name) + (url+commit->name url commit))) + (format log-port "retrieved commit ~a~%" commit) + (values (add-to-store store name #t "sha256" checkout + #:select? (negate dot-git?)) + commit))) + (lambda (key err . rest) + ;; XXX: 'swh-download' currently doesn't support submodules. + (when recursive? + (apply throw key err rest)) + + (pk 'err key err rest) + (match ref + (('commit . commit) + ;; Attempt to fetch COMMIT from SWH. + (call-with-temporary-directory + (lambda (directory) + (unless (swh-download url commit directory) + (apply throw key err rest)) + (values (add-to-store store (url+commit->name url commit) + #t "sha256" directory) + commit)))) + (_ + (apply throw key err rest)))))) (define (print-git-error port key args default-printer) (match args