From 7d9615bd0ea68118fdcff0765100cf5d73e81e58 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 29 Jan 2023 21:54:16 +0000 Subject: git: Deprecate call-with-file-in-git. Functions called by call-with-file-in-git may expect to read files directly off the filesystem. These functions are not all within the user's control and cannot be rewritten to do otherwise. It is more robust to provide a filesystem checkout of the git repository like these functions expect. In this commit, we deprecate call-with-file-in-git and replace calls to it with call-with-input-file. These invocations have been arranged such that they all happen at the top level of a repository checkout. * tissue/git.scm (call-with-file-in-git): Delete function. * .dir-locals.el (scheme-mode): Unregister it. * bin/tissue (tissue-show, load-config), tissue/file-document.scm (file-text, read-gemtext-document), tissue/issue.scm (read-gemtext-issue): Replace call-with-file-in-git with call-with-input-file. (pull, tissue-web): Call load-config from the top level of a repository checkout. --- tissue/file-document.scm | 4 ++-- tissue/git.scm | 22 ---------------------- tissue/issue.scm | 2 +- 3 files changed, 3 insertions(+), 25 deletions(-) (limited to 'tissue') diff --git a/tissue/file-document.scm b/tissue/file-document.scm index ccd6a48..f389976 100644 --- a/tissue/file-document.scm +++ b/tissue/file-document.scm @@ -71,7 +71,7 @@ (define (file-text file) "Return the contents of text @var{file}." - (call-with-file-in-git (current-git-repository) file + (call-with-input-file file get-string-all)) (define-method (document-text (document )) @@ -139,7 +139,7 @@ MSet object representing a list of search results." "Read gemtext document from @var{file} and return a @code{} object." (make - #:title (or (call-with-file-in-git (current-git-repository) file + #:title (or (call-with-input-file file (lambda (port) (port-transduce (tfilter-map (lambda (line) ;; The first level one diff --git a/tissue/git.scm b/tissue/git.scm index 4289d65..70f0de9 100644 --- a/tissue/git.scm +++ b/tissue/git.scm @@ -45,7 +45,6 @@ commit-author-date git-tracked-file? git-tracked-files - call-with-file-in-git file-modification-table clone-options call-with-temporary-checkout)) @@ -132,27 +131,6 @@ directory." directory of @var{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. PATH may refer -to a file on the filesystem or in REPOSITORY." - (let ((file-path (if (absolute-file-name? path) - ;; Treat absolute paths verbatim. - path - ;; Treat relative paths as relative to the - ;; top-level of the git repository. - (string-append (dirname (repository-directory repository)) - "/" path)))) - (if (file-exists? file-path) - ;; If file exists on the filesystem, read it. - (call-with-input-file file-path proc) - ;; Else, read the file from the 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-file-changes repository commit) "Return a list of pairs describing files modified by COMMIT with respect to its first parent in REPOSITORY. Each pair maps the old diff --git a/tissue/issue.scm b/tissue/issue.scm index ebfca52..1953cef 100644 --- a/tissue/issue.scm +++ b/tissue/issue.scm @@ -277,7 +277,7 @@ gemtext file." "Read issue from gemtext @var{file} and return an @code{} object." (let* ((file-document (read-gemtext-document file)) - (file-details (call-with-file-in-git (current-git-repository) file + (file-details (call-with-input-file file file-details)) ;; Downcase keywords to make them ;; case-insensitive. -- cgit v1.2.3