diff options
author | Tom Willemse | 2013-06-07 22:34:27 +0200 |
---|---|---|
committer | Tom Willemse | 2013-06-07 22:34:27 +0200 |
commit | b1a2359036aefa401b67943ae52f76a3a24bac53 (patch) | |
tree | 42741faded7177f7c94de07781ec459540b98606 /gitto/git.scm | |
parent | a936e985a468f8b32bd8812e624f8af52dac2ca3 (diff) | |
download | gitto-b1a2359036aefa401b67943ae52f76a3a24bac53.tar.gz gitto-b1a2359036aefa401b67943ae52f76a3a24bac53.zip |
Only show branches with changes by default
Unless `show-unchanged-branches?' has been set to `#t' in the user's
configuration only branches with pushable or pullable commits are shown.
Diffstat (limited to 'gitto/git.scm')
-rw-r--r-- | gitto/git.scm | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gitto/git.scm b/gitto/git.scm index 425e26e..83674be 100644 --- a/gitto/git.scm +++ b/gitto/git.scm @@ -22,6 +22,7 @@ #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) #:use-module (oop goops) + #:use-module (srfi srfi-1) #:export (<branch> <repository> @@ -37,6 +38,8 @@ repo-name same-repository?)) +(define show-unchanged-branches? #f) + (define-generic print) (define-generic same-repository?) @@ -136,9 +139,14 @@ sub-directory." (git-branches dir)))))) (define-method (print (branch <branch>)) - (format #t " ~a:~15t~d to push and ~d to pull. Last update: ~a~%" - (branch-name branch) (branch-pushable branch) - (branch-pullable branch) (branch-updated branch))) + (let ((pushable (branch-pushable branch)) + (pullable (branch-pullable branch))) + (if (or show-unchanged-branches? + (> (+ pushable pullable) 0)) + (format #t " ~a:~15t~d to push and ~d to pull. Last update: ~a~%" + (branch-name branch) pushable pullable + (branch-updated branch)) + #f))) (define (repo-state-description repo) "Return the state of REPO as either clean or dirty. @@ -151,8 +159,9 @@ REPO should be of type `<repository>' and the result is a string." (begin (format #t "~a: Worktree is ~a~%" (repo-name repo) (repo-state-description repo)) - (for-each print (repo-branches repo)) - (newline)) + (when (any identity (map-in-order print (repo-branches repo))) + (newline)) + #t) (format #t "~a:~15tnot found at ~s\n" (repo-name repo) (repo-location repo)))) |