[Bps-public-commit] git-sync branch, master, updated. e60b7b2e7761756d44ed7d7dcc297ffd435c3d61

Alex Vandiver alexmv at bestpractical.com
Tue Mar 30 22:34:17 EDT 2010


The branch, master has been updated
       via  e60b7b2e7761756d44ed7d7dcc297ffd435c3d61 (commit)
       via  090072f6ada3a07206bd7f5e5a6624a367e22a22 (commit)
      from  aa5b596072db09e8c5c1b370f18018381e178748 (commit)

Summary of changes:
 git-sync |   49 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit 090072f6ada3a07206bd7f5e5a6624a367e22a22
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 30 19:41:39 2010 -0400

    Add a "--quiet" that skips up-to-date, non-dirty repos

diff --git a/git-sync b/git-sync
index bcb0155..b38667f 100755
--- a/git-sync
+++ b/git-sync
@@ -6,7 +6,7 @@ git-sync - synchronize multiple git repositories
 
 =head1 SYNOPSIS
 
-    git-sync [--verbose] [--dry-run] [--log] [category]
+    git-sync [--verbose|--quiet] [--dry-run] [--log] [category]
 
 =head1 DESCRIPTION
 
@@ -135,6 +135,10 @@ value.
 
 Be more verbose about which repositories are skipped, and why.
 
+=item C<--quiet> or C<--terse> or C<-q>
+
+Skip the display of non-dirty, up-to-date repositories.
+
 =item C<--pretend> or C<--dry-run> or C<-n>
 
 Remote repositories are not fetched from; the list of repositories
@@ -189,15 +193,22 @@ $SIG{INT} = sub {
 };
 $SIG{USR1} = 'IGNORE';
 
-my ($verbose, $pretend, $log, $help);
+my ($verbose, $quiet, $pretend, $log, $help);
 GetOptions(
-    'verbose|v' => \$verbose,
+    'verbose|v!' => \$verbose,
+    'quiet|terse|q!' => \$quiet,
     'pretend|dry-run|n' => \$pretend,
     'log|l' => \$log,
     'help|h' => \$help,
 ) or pod2usage( -verbose => 1 );
+
+pod2usage( -verbose => 0, -msg => "--verbose and --quiet are mutually exclusive")
+    if $verbose and $quiet;
+
 pod2usage( -verbose => 2 ) if $help;
 
+$verbose = -$quiet if defined $quiet;
+
 my %sync;
 for (split /\0/, `git config -z --get-regexp ^sync\\\\.`) {
     next unless /^sync\.(.*?)\.([^\n]*)(?:\n(.*))?/;
@@ -205,6 +216,7 @@ for (split /\0/, `git config -z --get-regexp ^sync\\\\.`) {
         ? ref $sync{$1}{$2} ? [@{$sync{$1}{$2}}, $3] : [$sync{$1}{$2}, $3]
         : $3;
 }
+$verbose ||= 0;
 
 my @categories;
 if (@ARGV) {
@@ -371,12 +383,12 @@ sub sync_all_remote {
                 update($into, 1);
             } else {
                 `ssh $config{host} [ -e $repopath/config ]`;
-                print $verbose ? colored("[ Not a git repository ]\n", "dark") : "\r" and next
+                print $verbose > 0 ? colored("[ Not a git repository ]\n", "dark") : "\r" and next
                     if $?;
 
                 my ($ignore) = `ssh $config{host} git config --bool -f $repopath/config sync.ignore`;
                 chomp $ignore if defined $ignore;
-                print $verbose ? colored("[ sync.ignore set ]\n", "dark") : "\r" and next
+                print $verbose > 0 ? colored("[ sync.ignore set ]\n", "dark") : "\r" and next
                     if defined $ignore and $ignore eq 'true';
 
                 clone($into => "$config{host}:$repopath", $config{email});
@@ -449,7 +461,7 @@ sub already {
         print colored( "[ Already synchronized! ]\n", "red");
         return 1;
     } elsif (exists $seen{$path}) {
-        print $verbose ? colored("[ Already synchronized ]\n", "dark") : "\r";
+        print $verbose > 0 ? colored("[ Already synchronized ]\n", "dark") : "\r";
         return 1;
     }
     $seen{$path} = $force;
@@ -467,7 +479,7 @@ sub update {
     }
 
     if ( $repo->config_bool( "sync.ignore" )) {
-        print $verbose ? colored("[ sync.ignore set ]\n", "dark") : "\r";
+        print $verbose > 0 ? colored("[ sync.ignore set ]\n", "dark") : "\r";
         return;
     }
 
@@ -521,6 +533,7 @@ sub update {
         print $pull;
     } else {
         my $logs = "";
+        my $dirty = ($status !~ /^nothing (?:added )?to commit/m) ? 1 : 0;
         if ($status =~ /^# Your branch and '.*?' have diverged.*?(\d+) and (\d+) different commit/sm) {
             print colored( "[ Diverged by $1 and $2 commits ($branch) ]", "bold cyan" );
         } elsif ($status =~ /^# Your branch is ahead of '(.*?)' by (\d+) commit/m) {
@@ -531,12 +544,13 @@ sub update {
             my ($tracking, $behind) = ($1, $2);
             print colored( "[ Behind by $behind ($branch) ]", "bold magenta");
             $logs = logs($repo, $branch => $tracking);
+        } elsif ($verbose < 0 and not $dirty) {
+            print "\r", " " x 50, "\r";
+            return;
         } else {
             print colored( "[ Up-to-date ($branch) ]", "green");
         }
-        if ($status !~ /^nothing (?:added )?to commit/m) {
-            print colored( " [ Dirty ]", "yellow");
-        }
+        print colored( " [ Dirty ]", "yellow") if $dirty;
         print "\n$logs";
     }
 
@@ -552,7 +566,7 @@ sub clone {
     my $ret = eval { Git::command( [clone => "-q" => $from => $into], STDERR => 0 ) };
     if ($@) {
         print colored( "[ Clone failed! ]\n", "bold red");
-        print colored( "Error: $@\n", "red") if ($verbose);
+        print colored( "Error: $@\n", "red") if $verbose > 0;
         return undef;
     }
     kill $? & 127, $$ if $? & 127; # Propagate the signal it died with, if any

commit e60b7b2e7761756d44ed7d7dcc297ffd435c3d61
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 30 22:29:27 2010 -0400

    Add config settings for common options

diff --git a/git-sync b/git-sync
index b38667f..a417999 100755
--- a/git-sync
+++ b/git-sync
@@ -133,11 +133,14 @@ value.
 
 =item C<--verbose> or C<-v>
 
-Be more verbose about which repositories are skipped, and why.
+Be more verbose about which repositories are skipped, and why.  This
+option's default is controlled by the C<sync.verbose> key in
+F<.gitconfig>
 
 =item C<--quiet> or C<--terse> or C<-q>
 
-Skip the display of non-dirty, up-to-date repositories.
+Skip the display of non-dirty, up-to-date repositories.  This option's
+default is controlled bt the C<sync.quiet> key in F<.gitconfig>
 
 =item C<--pretend> or C<--dry-run> or C<-n>
 
@@ -150,7 +153,8 @@ L</Github> and L</Remote> directories.
 
 When a repository is ahead or behind its tracking remote (but not
 diverged), show the output of C<git log --oneline --reverse> for the
-list of commits that differ.
+list of commits that differ.  This option's default is controlled by
+the C<sync.log> key in F<.gitconfig>
 
 =item C<--help> or C<-h>
 
@@ -198,7 +202,7 @@ GetOptions(
     'verbose|v!' => \$verbose,
     'quiet|terse|q!' => \$quiet,
     'pretend|dry-run|n' => \$pretend,
-    'log|l' => \$log,
+    'log|l!' => \$log,
     'help|h' => \$help,
 ) or pod2usage( -verbose => 1 );
 
@@ -211,6 +215,9 @@ $verbose = -$quiet if defined $quiet;
 
 my %sync;
 for (split /\0/, `git config -z --get-regexp ^sync\\\\.`) {
+    $verbose =  1 if not defined $verbose and $_ eq "sync.verbose";
+    $verbose = -1 if not defined $verbose and $_ eq "sync.quiet";
+    $log     =  1 if not defined $log     and $_ eq "sync.log";
     next unless /^sync\.(.*?)\.([^\n]*)(?:\n(.*))?/;
     $sync{$1}{$2} = exists $sync{$1}{$2}
         ? ref $sync{$1}{$2} ? [@{$sync{$1}{$2}}, $3] : [$sync{$1}{$2}, $3]

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list