From 7db5c16efe41ed0e57be24125f21edf94e78429e Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 3 Jul 2022 01:43:45 +0530 Subject: git: Add call-with-file-in-git utility. * tissue/git.scm (call-with-file-in-git): New public function. --- tissue/git.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tissue') 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 objects created by COMMIT with respect to its first parent in REPOSITORY." -- cgit v1.2.3