git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
MLMartin Langhoff <martin@catalyst.net.nz>
Date
Jan 9, 2007, 02:10 UTC
Message-ID
<11683086324018-git-send-email-martin@catalyst.net.nz>

if the SHA1 of our head matches the last SHA1 seen in the DB, avoid further processing.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
---
 git-cvsserver.perl |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index df39512..0b75f9c 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -2184,7 +2184,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 +2197,10 @@ sub update
     my $git_log;
     my $lastcommit = $self->_get_prop("last_commit");
 
+    if ($lastcommit eq $commitsha1) { # up-to-date
+         return 1;
+    }
+
     # Start exclusive lock here...
     $self->{dbh}->begin_work() or die "Cannot lock database for BEGIN";
 
-- 
1.5.0.rc0.g4017-dirty
Next: Martin Langhoff
Message 1 of 3 in “cvsserver: detect early of we are up to date and avoid costly rev-list”
  1. cvsserver: detect early of we are up to date and avoid costly rev-listMartin Langhoff, Jan 9, 2007
  2. Martin LanghoffJan 9, 2007
  3. Junio C HamanoJan 9, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.