- system 'rsync', '-avv', "root\@$hostname:$path", "$hostname/$path" if $path;
- $message ||= "$command $hostname $path";
- system 'git', 'commit', '-m', $message, "$hostname/$path";
- } elsif ( $command =~ m{(diff|status|log)} ) {
- my $opt = '--summary' if $command eq 'log';
- print $client `git $command $opt $hostname`;
+ pull_changes $hostname;
+ $message =~ s/'/\\'/g;
+ $user =~ s/\/$//;
+ print $client git( "commit -m '$message' --author '$user <$hostname>' $backup_path" );
+ } elsif ( $command =~ m{(diff|status|log|ch)} ) {
+ $command .= ' --stat' if $command eq 'log';
+ $command = 'log --patch-with-stat' if $command =~ m/^ch/;
+ pull_changes( $hostname ) if $command eq 'diff';
+ if ( $on_host ) {
+ system 'rsync', '-avv', "root\@$on_host:$path", "$on_host/$path";
+ open(my $diff, '-|', "diff -Nuw $hostname$path $on_host$path");
+ while(<$diff>) {
+ print $client $_;
+ }
+ } else {
+ # commands without path will show host-wide status/changes
+ print $client git($command, $rel_path ? $backup_path : $hostname);
+ }