From 162176fddbc235c52b40da0dc4d74aae63b2c0d3 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 6 Apr 2022 17:28:08 +0530 Subject: git: Implement git-top-level independent of the git command. * tissue/git.scm (git-top-level): Implement independent of the git command. --- tissue/git.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tissue/git.scm b/tissue/git.scm index 50da06b..8be3970 100644 --- a/tissue/git.scm +++ b/tissue/git.scm @@ -25,10 +25,16 @@ git-tracked-files)) (define (git-top-level) - "Return the top-level directory of the current git repository." - (call-with-input-pipe - get-line - "git" "rev-parse" "--show-toplevel")) + "Return the top-level directory of the current git +repository." + (let loop ((curdir (getcwd))) + (cond + ((file-exists? (string-append curdir "/.git")) + curdir) + ((string=? curdir "/") + (error "No git top level found")) + (else + (loop (dirname curdir)))))) (define (git-tracked-files) "Return a list of all files tracked in the current git repository." -- cgit v1.2.3