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

3 messages from 2007-01-09 to 2007-01-09. Participants: Martin Langhoff, Junio C Hamano.
Thread: https://gitlist.dev/t/6291

## Martin Langhoff, 2007-01-09 02:10

Subject: [PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list
Message-ID: <11683086324018-git-send-email-martin@catalyst.net.nz>
URL: https://gitlist.dev/e/11683086324018-git-send-email-martin%40catalyst.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

```

## Martin Langhoff, 2007-01-09 02:39

Subject: Re: [PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list
Message-ID: <46a038f90701081839r5727c6a0qbcab1cb02dcef580@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90701081839r5727c6a0qbcab1cb02dcef580%40mail.gmail.com
In-Reply-To: <11683086324018-git-send-email-martin@catalyst.net.nz>

```
On 1/9/07, Martin Langhoff <martin@catalyst.net.nz> wrote:
> @@ -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";

Actually, that generates a warning on the initial checkout. The fix is
to run the if as

  if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date

Junio -- is it easy for you to fixup  when you apply the patch?
Otherwise, I'll be happy to repost it patch.

cheers


m

```

## Junio C Hamano, 2007-01-09 05:44

Subject: Re: [PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list
Message-ID: <7vzm8ssqij.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vzm8ssqij.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <46a038f90701081839r5727c6a0qbcab1cb02dcef580@mail.gmail.com>

```
"Martin Langhoff" <martin.langhoff@gmail.com> writes:

> On 1/9/07, Martin Langhoff <martin@catalyst.net.nz> wrote:
>> @@ -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";
>
> Actually, that generates a warning on the initial checkout. The fix is
> to run the if as
>
>  if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date
>
> Junio -- is it easy for you to fixup  when you apply the patch?
> Otherwise, I'll be happy to repost it patch.

Thanks but no need.  "git commit --amend" is our friend ;-).

```
