+ if ( $on_host ) {
+ rsync( '-avv', "$on_host/$path", "root\@$hostname:$path" );
+ } else {
+ print $client git "checkout -- $hostname/$path";
+ rsync( '-avv', "$hostname/$path", "root\@$hostname:$path" );
+ }
+ } elsif ( $command eq 'cat' ) {
+ my $file_path = ( $on_host ? $on_host : $hostname ) . "/$path";
+ if ( -r $file_path ) {
+ open(my $file, '<', $file_path) || warn "ERROR $file_path: $!";
+ while(<$file>) {
+ print $client $_;
+ }
+ close($file);
+ } else {
+ print $client "ERROR: $file_path: $!\n";
+ }
+ } elsif ( $command eq 'ls' ) {
+ my $file_path = ( $on_host ? $on_host : $hostname ) . "/$path";
+ print $client `ls $file_path 2>&1`;
+ } elsif ( $command eq 'show' ) {
+ print $client `git show $rel_path`;
+ } elsif ( $command eq 'grep' ) {
+ print $client `git log -g --grep=$rel_path`;
+ } elsif ( $command eq 'find' ) {
+ print $client `find . -iname '*$rel_path*' | sed -e 's,^./,,' -e 's,/,:/,'`
+ } elsif ( $command eq 'link' ) {
+ if ( $on_host ) {
+ mkbasedir "$on_host/$path";
+ rsync( '-avv', "root\@$on_host:$path", "$on_host/$path" );
+ mkbasedir "$hostname/$path";
+ link "$on_host/$path", "$hostname/$path";
+ rsync( '-avv', "$hostname/$path", "root\@$hostname:$path" );
+ } else {
+ print $client "ERROR: link requires host:/path\n";
+ }