diff --git a/lang/rust/src/registry.sld b/lang/rust/src/registry.sld index 77a657b..5275a93 100644 --- a/lang/rust/src/registry.sld +++ b/lang/rust/src/registry.sld @@ -127,7 +127,9 @@ (create-directory repo #t) (let-values (((_ _ _) (process-wait (process-run "git" (list "init" "--bare" repo))))) #f)) - (define-values (_ _ _) (process-wait (process-run "git" (list "-C" repo "fetch" "--write-fetch-head" url refspec)))) + (define-values (_ commit-exists _) (process-wait (process-run "git" (list "-C" repo "cat-file" "-e" refspec)))) + (unless commit-exists + (let-values (((_ _ _) (process-wait (process-run "git" (list "-C" repo "fetch" "--write-fetch-head" url refspec))))) #f)) (define tree (read-git-tree repo (string-append refspec ":"))) (define subdir (find-matching-cargo tree name)) (unless subdir (error "could not find package in git repo" (list url refspec name)))