X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-cvsserver.perl;h=84520e7ad5c1745b14db2206189bb7d54c17dcc8;hb=7447b4bc837d2f73fb4cd34f2a44a0cb120c5c39;hp=df395126b86bbed4d8f785e7eccbdb091c3f888b;hpb=37818d7db070f67a20df58ac7d5e04cc63ef1867;p=git.git diff --git a/git-cvsserver.perl b/git-cvsserver.perl index df395126b..84520e7ad 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -172,11 +172,11 @@ sub req_Root return 0; } - my @gitvars = `git-repo-config -l`; + my @gitvars = `git-config -l`; if ($?) { - print "E problems executing git-repo-config on the server -- this is not a git repository or the PATH is not set correctly.\n"; + print "E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\n"; print "E \n"; - print "error 1 - problem executing git-repo-config\n"; + print "error 1 - problem executing git-config\n"; return 0; } foreach my $line ( @gitvars ) @@ -876,9 +876,9 @@ sub req_update print "MT newline\n"; next; } - elsif ( !defined($wrev) || $wrev == 0 ) + elsif ( (!defined($wrev) || $wrev == 0) && (!defined($meta->{revision}) || $meta->{revision} == 0) ) { - $log->info("Tell the client the file will be added"); + $log->info("Tell the client the file is scheduled for addition"); print "MT text A \n"; print "MT fname $filename\n"; print "MT newline\n"; @@ -886,7 +886,7 @@ sub req_update } else { - $log->info("Updating '$filename' $wrev"); + $log->info("Updating '$filename' to ".$meta->{revision}); print "MT +updated\n"; print "MT text U \n"; print "MT fname $filename\n"; @@ -1171,6 +1171,21 @@ sub req_ci exit; } + # Check that this is allowed, just as we would with a receive-pack + my @cmd = ( $ENV{GIT_DIR}.'hooks/update', "refs/heads/$state->{module}", + $parenthash, $commithash ); + if( -x $cmd[0] ) { + unless( system( @cmd ) == 0 ) + { + $log->warn("Commit failed (update hook declined to update ref)"); + print "error 1 Commit failed (update hook declined)\n"; + close LOCKFILE; + unlink($lockfile); + chdir "/"; + exit; + } + } + print LOCKFILE $commithash; $updater->update(); @@ -1181,12 +1196,15 @@ sub req_ci $filename = filecleanup($filename); my $meta = $updater->getmeta($filename); + unless (defined $meta->{revision}) { + $meta->{revision} = 1; + } my ( $filepart, $dirpart ) = filenamesplit($filename, 1); $log->debug("Checked-in $dirpart : $filename"); - if ( $meta->{filehash} eq "deleted" ) + if ( defined $meta->{filehash} && $meta->{filehash} eq "deleted" ) { print "Remove-entry $dirpart\n"; print "$filename\n"; @@ -2184,7 +2202,10 @@ sub update # first lets get the commit list $ENV{GIT_DIR} = $self->{git_path}; - my $commitinfo = `git-cat-file commit $self->{module} 2>&1`; + my $commitsha1 = `git rev-parse $self->{module}`; + chomp $commitsha1; + + my $commitinfo = `git cat-file commit $self->{module} 2>&1`; unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ ) { die("Invalid module '$self->{module}'"); @@ -2194,6 +2215,10 @@ sub update my $git_log; my $lastcommit = $self->_get_prop("last_commit"); + if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date + return 1; + } + # Start exclusive lock here... $self->{dbh}->begin_work() or die "Cannot lock database for BEGIN";