git: Do not add '.git' to the store.

This makes 'latest-repository-commit' significantly more efficient and
reduces disk usage in the store.

* guix/git.scm (copy-to-store)[dot-git?]: New procedure.
Pass it as the #:select? argument to 'add-to-store'.
This commit is contained in:
Ludovic Courtès 2017-11-21 15:25:57 +01:00
parent a6591381fc
commit fe9b3ec3ee
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 9 additions and 3 deletions

View File

@ -80,11 +80,17 @@ of SHA1 string."
"-" (string-take sha1 7))) "-" (string-take sha1 7)))
(define* (copy-to-store store cache-directory #:key url repository) (define* (copy-to-store store cache-directory #:key url repository)
"Copy items in cache-directory to store. URL and REPOSITORY are used "Copy CACHE-DIRECTORY recursively to STORE. URL and REPOSITORY are used to
to forge store directory name." create the store directory name."
(define (dot-git? file stat)
(and (string=? (basename file) ".git")
(eq? 'directory (stat:type stat))))
(let* ((commit (repository->head-sha1 repository)) (let* ((commit (repository->head-sha1 repository))
(name (url+commit->name url commit))) (name (url+commit->name url commit)))
(values (add-to-store store name #t "sha256" cache-directory) commit))) (values (add-to-store store name #t "sha256" cache-directory
#:select? (negate dot-git?))
commit)))
(define (switch-to-ref repository ref) (define (switch-to-ref repository ref)
"Switch to REPOSITORY's branch, commit or tag specified by REF." "Switch to REPOSITORY's branch, commit or tag specified by REF."