aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-06-07 22:34:27 +0200
committerGravatar Tom Willemse2013-06-07 22:34:27 +0200
commitb1a2359036aefa401b67943ae52f76a3a24bac53 (patch)
tree42741faded7177f7c94de07781ec459540b98606
parenta936e985a468f8b32bd8812e624f8af52dac2ca3 (diff)
downloadgitto-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.
-rw-r--r--doc/gitto.texi7
-rw-r--r--gitto/git.scm19
2 files changed, 21 insertions, 5 deletions
diff --git a/doc/gitto.texi b/doc/gitto.texi
index 6537b7e..b109769 100644
--- a/doc/gitto.texi
+++ b/doc/gitto.texi
@@ -339,6 +339,13 @@ A plain list of repository names to skip when merging configurations and
installing hooks.
@end defopt
+@defopt show-unchanged-branches?
+A boolean. If @code{#t} all branches will be shown no matter their
+state, if @code{#f} (the default) only those branches that either have
+commits to push or commits to pull will be shown in the output of the
+@samp{list} command.
+@end defopt
+
@node Copying This Manual, Index, Configuration, Top
@appendix Copying This Manual
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))))