summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tissue/git.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/tissue/git.scm b/tissue/git.scm
index c7b1fcc..d557984 100644
--- a/tissue/git.scm
+++ b/tissue/git.scm
@@ -33,6 +33,7 @@
current-git-repository
commit-date
git-tracked-files
+ call-with-file-in-git
file-modification-table))
;; We bind additional functions from libgit2 that are not already
@@ -79,6 +80,15 @@ returned paths are relative to the top-level directory of REPOSITORY
and do not have a leading slash."
(tree-list (head-tree repository)))
+(define (call-with-file-in-git repository path proc)
+ "Call PROC on an input port reading contents of PATH in REPOSITORY."
+ (let* ((path-tree-entry (tree-entry-bypath (head-tree repository)
+ path))
+ (path-object (tree-entry->object repository path-tree-entry))
+ (blob (blob-lookup repository (object-id path-object))))
+ (call-with-port (open-bytevector-input-port (blob-content blob))
+ proc)))
+
(define (commit-deltas repository commit)
"Return the list of <diff-delta> objects created by COMMIT with
respect to its first parent in REPOSITORY."