diff options
-rw-r--r-- | .dir-locals.el | 2 | ||||
-rw-r--r-- | tissue/git.scm | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/.dir-locals.el b/.dir-locals.el index f6bf9b6..8c01904 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -8,6 +8,8 @@ (scheme-mode (eval . (put 'call-with-current-directory 'scheme-indent-function 1)) (eval . (put 'call-with-file-in-git 'scheme-indent-function 2)) + (eval . (put 'call-with-temporary-checkout 'scheme-indent-function 1)) + (eval . (put 'call-with-temporary-checkouts 'scheme-indent-function 1)) (eval . (put 'function-documentation 'scheme-indent-function 2)) (eval . (put 'docstring-function-documentation 'scheme-indent-function 2)) (eval . (put 'with-ellipsis 'scheme-indent-function 1)) diff --git a/tissue/git.scm b/tissue/git.scm index 562e715..653f8ae 100644 --- a/tissue/git.scm +++ b/tissue/git.scm @@ -47,7 +47,9 @@ git-tracked-files call-with-file-in-git file-modification-table - clone-options)) + clone-options + call-with-temporary-checkout + call-with-temporary-checkouts)) ;; We bind additional functions from libgit2 that are not already ;; bound in guile-git. TODO: Contribute them to guile-git. @@ -211,3 +213,22 @@ that modified them." 'bare (if bare? 1 0)) clone-options)) + +(define (call-with-temporary-checkout repository proc) + "Call PROC with a temporary checkout of REPOSITORY, and delete the +checkout when PROC returns or exits non-locally." + (call-with-temporary-directory + (lambda (temporary-checkout) + (clone repository temporary-checkout) + (proc temporary-checkout)))) + +(define (call-with-temporary-checkouts repositories proc) + "Call PROC with temporary checkouts of REPOSITORIES, and delete the +checkouts when PROC returns or exits non-locally." + (match repositories + ((repository other-repositories ...) + (call-with-temporary-checkout repository + (lambda (checkout) + (call-with-temporary-checkouts other-repositories + (cut proc checkout <...>))))) + (() (proc)))) |