From 8d1a7c94cc28535f9854ed5f882e15e8ad04d97c Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 18 Feb 2010 16:19:26 +0100 Subject: [PATCH] pull_changes before diff --- bak-git-server.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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`; -- 2.20.1