aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-11-10 21:30:51 +0100
committerGravatar Tom Willemse2013-11-10 21:30:51 +0100
commitf81fcc9a8a04d47bd1c4b158c2f1c5d592e79776 (patch)
treeffba472c6549057a2677e4aabbd55ed9063eb01e
parentaab22cbb6e033b731fa00cf6fc83196aa60442dd (diff)
downloadgitto-f81fcc9a8a04d47bd1c4b158c2f1c5d592e79776.tar.gz
gitto-f81fcc9a8a04d47bd1c4b158c2f1c5d592e79776.zip
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 `<repository>' instance nor a string it's sure that it's also not a registered repository.
-rw-r--r--gitto/git.scm7
-rw-r--r--gitto/main.scm9
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 <repository>))
+
(define-method (branch-pullable (branch <branch>))
(force (slot-ref branch 'pullable)))
@@ -180,6 +184,9 @@ REPO should be of type `<repository>' and the result is a string."
(define-method (same-repository? (x <string>) (y <repository>))
(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."