From f81fcc9a8a04d47bd1c4b158c2f1c5d592e79776 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 10 Nov 2013 21:30:51 +0100 Subject: Make sure to deal with a repository When checking when a repository is known or not be sure that there is actually a chance that we are looking at a repository. If the thing to be checked is neither a `' instance nor a string it's sure that it's also not a registered repository. --- gitto/git.scm | 7 +++++++ gitto/main.scm | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gitto/git.scm b/gitto/git.scm index 83674be..be91042 100644 --- a/gitto/git.scm +++ b/gitto/git.scm @@ -36,6 +36,7 @@ repo-clean? repo-location repo-name + repository? same-repository?)) (define show-unchanged-branches? #f) @@ -55,6 +56,9 @@ (clean? #:getter repo-clean?) (branches #:getter repo-branches)) +(define (repository? repo) + (is-a? repo )) + (define-method (branch-pullable (branch )) (force (slot-ref branch 'pullable))) @@ -180,6 +184,9 @@ REPO should be of type `' and the result is a string." (define-method (same-repository? (x ) (y )) (string= x (repo-location y))) +(define-method (same-repository? x y) + #f) + (define* (start-git dir args #:optional (extra "")) (open-input-pipe (format #f "git --work-tree=~s --git-dir=\"~a/.git\" ~a 2>/dev/null ~a" diff --git a/gitto/main.scm b/gitto/main.scm index 3c82e49..7ccfb34 100644 --- a/gitto/main.scm +++ b/gitto/main.scm @@ -100,9 +100,12 @@ COMMAND." (define (known? repo) "Do we know REPO?" - (or (member repo repositories same-repository?) - (member (realpath (if (string? repo) repo (repo-location repo))) - repositories same-repository?))) + (and (or (repository? repo) (string? repo)) + (or (member repo repositories same-repository?) + (member (realpath (if (string? repo) + repo + (repo-location repo))) + repositories same-repository?)))) (define (save-repositories-list) "Save the list of repositories." -- cgit v1.2.3-54-g00ecf