always prefix message with originating host
[bak-git.git] / bak-git-server.pl
index 1a074da..f25e926 100755 (executable)
@@ -97,14 +97,14 @@ while (my $client = $server->accept()) {
        my $line = <$client>;
        chomp($line);
        warn "<<< $line\n";
-       my ($user,$hostname,$pwd,$command,$rel_path,$message) = split(/\s+/,$line,5);
+       my ($user,$hostname,$pwd,$command,$rel_path,$message) = split(/\s+/,$line,6);
 
        my $on_host = $1 if $rel_path =~ s/^([^:]+):(.+)$/$2/ && -e $1;
        my $path = $rel_path =~ m{^/} ? $rel_path : "$pwd/$rel_path";
 
-       $message ||= '';
-       warn "$hostname [$command] $path | $message\n";
-       $message ||= "$hostname [$command] $path";
+       warn "$hostname [$command] $on_host:$path | $message\n";
+       $message ||= "$path [$command]";
+       $message = "$hostname: $message";
 
        my $dir = $path;
        $dir =~ s{/[^/]+$}{};
@@ -136,7 +136,7 @@ while (my $client = $server->accept()) {
                pull_changes $hostname if $command eq 'diff';
                if ( $on_host ) {
                        system 'rsync', '-avv', "root\@$on_host:$path", "$on_host/$path";
-                       open(my $diff, '-|', "diff -uw $hostname$path $on_host$path");
+                       open(my $diff, '-|', "diff -Nuw $hostname$path $on_host$path");
                        while(<$diff>) {
                                print $client $_;
                        }