From: Dobrica Pavlinusic Date: Thu, 18 Feb 2010 15:19:26 +0000 (+0100) Subject: pull_changes before diff X-Git-Url: http://git.rot13.org/?p=bak-git.git;a=commitdiff_plain;h=8d1a7c94cc28535f9854ed5f882e15e8ad04d97c pull_changes before diff --- diff --git a/bak-git-server.pl b/bak-git-server.pl index 7fb2ac3..b3925ba 100755 --- a/bak-git-server.pl +++ b/bak-git-server.pl @@ -74,6 +74,12 @@ warn "dir: $dir listen: $server_ip:9001\n" , $shell_client ; +sub pull_changes { + my $hostname = shift; + system "find $hostname -type f | sed 's,$hostname,,' > /tmp/$hostname.list"; + system "rsync -avv --files-from /tmp/$hostname.list root\@$hostname:/ $hostname/" +} + while (my $client = $server->accept()) { my ($hostname,$pwd,$command,$path,$message) = split(/\s+/,<$client>,5); @@ -89,8 +95,7 @@ while (my $client = $server->accept()) { mkpath "$hostname/$dir" unless -e "$hostname/$dir"; if ( ! $command ) { - system "find $hostname -type f | sed 's,$hostname,,' > /tmp/$hostname.list"; - system "rsync -avv --files-from /tmp/$hostname.list root\@$hostname:/ $hostname/" + pull_changes $hostname; } elsif ( $command eq 'add' ) { system 'rsync', '-avv', "root\@$hostname:$path", "$hostname/$path"; system 'git', 'add', "$hostname/$path"; @@ -100,6 +105,7 @@ while (my $client = $server->accept()) { system 'git', 'commit', '-m', $message, "$hostname/$path"; } elsif ( $command =~ m{(diff|status|log)} ) { my $opt = '--summary' if $command eq 'log'; + pull_changes $hostname if $command eq 'diff'; print $client `git $command $opt $hostname`; } elsif ( $command eq 'revert' ) { print $client `git checkout -- $hostname/$path`;