From 3ccf00c699de35d409bf8152d16617f54f97e4f1 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 20 Jul 2022 16:25:08 +0530 Subject: git: Add git-tracked-file? utility. * tissue/git.scm: Import (rnrs exceptions). (git-tracked-file?): New public function. --- tissue/git.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tissue/git.scm b/tissue/git.scm index 1f6c0ef..166ebd3 100644 --- a/tissue/git.scm +++ b/tissue/git.scm @@ -19,6 +19,7 @@ (define-module (tissue git) #:use-module (rnrs arithmetic bitwise) #:use-module (rnrs conditions) + #:use-module (rnrs exceptions) #:use-module (rnrs hashtables) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) @@ -42,6 +43,7 @@ %current-git-repository current-git-repository commit-author-date + git-tracked-file? git-tracked-files call-with-file-in-git file-modification-table @@ -108,6 +110,17 @@ directory." (time-time time)) (* 60 (time-offset time))))) +(define (git-tracked-file? path repository) + "Return non-#f if PATH is a file tracked in REPOSITORY. Else, return +#f." + (guard (c ((let ((git-error (condition-git-error c))) + (and git-error + (= (git-error-code git-error) + GIT_ENOTFOUND))) + #f)) + (tree-entry-bypath (head-tree repository) + path))) + (define* (git-tracked-files #:optional (repository (current-git-repository))) "Return a list of all files and directories tracked in REPOSITORY. The returned paths are relative to the top-level directory of REPOSITORY -- cgit v1.2.3