summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-07-03 01:43:45 +0530
committerArun Isaac2022-07-03 23:21:41 +0530
commit7db5c16efe41ed0e57be24125f21edf94e78429e (patch)
tree23f96dae63d671efb3e0063c6eec2fa8e2398902
parent4d5db55c18ababbb1b37ecabb4db55625d2ef554 (diff)
downloadtissue-7db5c16efe41ed0e57be24125f21edf94e78429e.tar.gz
tissue-7db5c16efe41ed0e57be24125f21edf94e78429e.tar.lz
tissue-7db5c16efe41ed0e57be24125f21edf94e78429e.zip
git: Add call-with-file-in-git utility.
* tissue/git.scm (call-with-file-in-git): New public function.
-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."