@matheusbsbs / matheus-bagliano / commits / 49fb940e40
Fork 0

cvsserver: detect early of we are up to date and avoid costly rev-list

if the SHA1 of our head matches the last SHA1 seen in the DB, avoid further processing. [jc: an "Oops, please amend" patch rolled in] Signed-off-by: Martin Langhoff <martin@catalyst.net.nz> Signed-off-by: Junio C Hamano <junkio@cox.net>

Martin Langhoff committed Jan 9, 2007 at 15:10 UTC 49fb940e4025f36953cd938576ec8306335c6cd0
1 file changed +8 -1
git-cvsserver.perl
+8 -1
@@ -2184,7 +2184,10 @@ sub update
2184 # first lets get the commit list
2185 $ENV{GIT_DIR} = $self->{git_path};
2186
2187 - my $commitinfo = `git-cat-file commit $self->{module} 2>&1`;
2187 + my $commitsha1 = `git rev-parse $self->{module}`;
2188 + chomp $commitsha1;
2189 +
2190 + my $commitinfo = `git cat-file commit $self->{module} 2>&1`;
2191 unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ )
2192 {
2193 die("Invalid module '$self->{module}'");
@@ -2194,6 +2197,10 @@ sub update
2197 my $git_log;
2198 my $lastcommit = $self->_get_prop("last_commit");
2199
2200 + if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date
2201 + return 1;
2202 + }
2203 +
2204 # Start exclusive lock here...
2205 $self->{dbh}->begin_work() or die "Cannot lock database for BEGIN";
2206