X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=git-cvsserver.perl;h=a33a876ff652fea5a0a8933b919982557a7093de;hb=191453f66449537da29e9fc156f7a981845ea8f6;hp=08ad831a3900d4ac0bc04b4e9bd371ffcb54e1ae;hpb=2dcd3ce8d38101d87c2d329cf46387038ac2c766;p=git.git diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 08ad831a3..a33a876ff 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -17,6 +17,7 @@ use strict; use warnings; +use bytes; use Fcntl; use File::Temp qw/tempdir tempfile/; @@ -945,7 +946,7 @@ sub req_update $log->debug("Temporary directory for merge is $dir"); - my $return = system("merge", $file_local, $file_old, $file_new); + my $return = system("git", "merge-file", $file_local, $file_old, $file_new); $return >>= 8; if ( $return == 0 ) @@ -1180,12 +1181,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"; @@ -2118,9 +2122,17 @@ sub new mode TEXT NOT NULL ) "); + $self->{dbh}->do(" + CREATE INDEX revision_ix1 + ON revision (name,revision) + "); + $self->{dbh}->do(" + CREATE INDEX revision_ix2 + ON revision (name,commithash) + "); } - # Construct the revision table if required + # Construct the head table if required unless ( $self->{tables}{head} ) { $self->{dbh}->do(" @@ -2134,6 +2146,10 @@ sub new mode TEXT NOT NULL ) "); + $self->{dbh}->do(" + CREATE INDEX head_ix1 + ON head (name) + "); } # Construct the properties table if required @@ -2171,7 +2187,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}'"); @@ -2181,6 +2200,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"; @@ -2331,67 +2354,72 @@ sub update if ( defined ( $lastpicked ) ) { - my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!"); + my $filepipe = open(FILELIST, '-|', 'git-diff-tree', '-z', '-r', $lastpicked, $commit->{hash}) or die("Cannot call git-diff-tree : $!"); + local ($/) = "\0"; while ( ) { - unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)\s+(.*)$/o ) + chomp; + unless ( /^:\d{6}\s+\d{3}(\d)\d{2}\s+[a-zA-Z0-9]{40}\s+([a-zA-Z0-9]{40})\s+(\w)$/o ) { die("Couldn't process git-diff-tree line : $_"); } + my ($mode, $hash, $change) = ($1, $2, $3); + my $name = ; + chomp($name); - # $log->debug("File mode=$1, hash=$2, change=$3, name=$4"); + # $log->debug("File mode=$mode, hash=$hash, change=$change, name=$name"); my $git_perms = ""; - $git_perms .= "r" if ( $1 & 4 ); - $git_perms .= "w" if ( $1 & 2 ); - $git_perms .= "x" if ( $1 & 1 ); + $git_perms .= "r" if ( $mode & 4 ); + $git_perms .= "w" if ( $mode & 2 ); + $git_perms .= "x" if ( $mode & 1 ); $git_perms = "rw" if ( $git_perms eq "" ); - if ( $3 eq "D" ) + if ( $change eq "D" ) { - #$log->debug("DELETE $4"); - $head->{$4} = { - name => $4, - revision => $head->{$4}{revision} + 1, + #$log->debug("DELETE $name"); + $head->{$name} = { + name => $name, + revision => $head->{$name}{revision} + 1, filehash => "deleted", commithash => $commit->{hash}, modified => $commit->{date}, author => $commit->{author}, mode => $git_perms, }; - $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); } - elsif ( $3 eq "M" ) + elsif ( $change eq "M" ) { - #$log->debug("MODIFIED $4"); - $head->{$4} = { - name => $4, - revision => $head->{$4}{revision} + 1, - filehash => $2, + #$log->debug("MODIFIED $name"); + $head->{$name} = { + name => $name, + revision => $head->{$name}{revision} + 1, + filehash => $hash, commithash => $commit->{hash}, modified => $commit->{date}, author => $commit->{author}, mode => $git_perms, }; - $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); } - elsif ( $3 eq "A" ) + elsif ( $change eq "A" ) { - #$log->debug("ADDED $4"); - $head->{$4} = { - name => $4, + #$log->debug("ADDED $name"); + $head->{$name} = { + name => $name, revision => 1, - filehash => $2, + filehash => $hash, commithash => $commit->{hash}, modified => $commit->{date}, author => $commit->{author}, mode => $git_perms, }; - $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); + $self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms); } else { - $log->warn("UNKNOWN FILE CHANGE mode=$1, hash=$2, change=$3, name=$4"); + $log->warn("UNKNOWN FILE CHANGE mode=$mode, hash=$hash, change=$change, name=$name"); die; } } @@ -2400,10 +2428,12 @@ sub update # this is used to detect files removed from the repo my $seen_files = {}; - my $filepipe = open(FILELIST, '-|', 'git-ls-tree', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!"); + my $filepipe = open(FILELIST, '-|', 'git-ls-tree', '-z', '-r', $commit->{hash}) or die("Cannot call git-ls-tree : $!"); + local $/ = "\0"; while ( ) { - unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\s+(.*)$/o ) + chomp; + unless ( /^(\d+)\s+(\w+)\s+([a-zA-Z0-9]+)\t(.*)$/o ) { die("Couldn't process git-ls-tree line : $_"); }