{"thread":{"id":"6291","subject":"[PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list","startedAt":"2007-01-09T02:10:32Z","lastAt":"2007-01-09T05:44:36Z","messageCount":3,"participants":["Martin Langhoff","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31177","messageId":"11683086324018-git-send-email-martin@catalyst.net.nz","threadId":"6291","inReplyTo":null,"subject":"[PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2007-01-09T02:10:32Z","receivedAt":"2007-01-09T02:10:32Z","isPatch":true,"sender":{"key":"martin@laptop.org","avatar":null},"body":"if the SHA1 of our head matches the last SHA1 seen in the DB, avoid further\nprocessing.\n\nSigned-off-by: Martin Langhoff <martin@catalyst.net.nz>\n---\n git-cvsserver.perl |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex df39512..0b75f9c 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -2184,7 +2184,10 @@ sub update\n     # first lets get the commit list\n     $ENV{GIT_DIR} = $self->{git_path};\n \n-    my $commitinfo = `git-cat-file commit $self->{module} 2>&1`;\n+    my $commitsha1 = `git rev-parse $self->{module}`;\n+    chomp $commitsha1;\n+\n+    my $commitinfo = `git cat-file commit $self->{module} 2>&1`;\n     unless ( $commitinfo =~ /tree\\s+[a-zA-Z0-9]{40}/ )\n     {\n         die(\"Invalid module '$self->{module}'\");\n@@ -2194,6 +2197,10 @@ sub update\n     my $git_log;\n     my $lastcommit = $self->_get_prop(\"last_commit\");\n \n+    if ($lastcommit eq $commitsha1) { # up-to-date\n+         return 1;\n+    }\n+\n     # Start exclusive lock here...\n     $self->{dbh}->begin_work() or die \"Cannot lock database for BEGIN\";\n \n-- \n1.5.0.rc0.g4017-dirty\n"},{"id":"31180","messageId":"46a038f90701081839r5727c6a0qbcab1cb02dcef580@mail.gmail.com","threadId":"6291","inReplyTo":"11683086324018-git-send-email-martin@catalyst.net.nz","subject":"Re: [PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2007-01-09T02:39:46Z","receivedAt":"2007-01-09T02:39:46Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 1/9/07, Martin Langhoff <martin@catalyst.net.nz> wrote:\n> @@ -2194,6 +2197,10 @@ sub update\n>      my $git_log;\n>      my $lastcommit = $self->_get_prop(\"last_commit\");\n>\n> +    if ($lastcommit eq $commitsha1) { # up-to-date\n> +         return 1;\n> +    }\n> +\n>      # Start exclusive lock here...\n>      $self->{dbh}->begin_work() or die \"Cannot lock database for BEGIN\";\n\nActually, that generates a warning on the initial checkout. The fix is\nto run the if as\n\n  if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date\n\nJunio -- is it easy for you to fixup  when you apply the patch?\nOtherwise, I'll be happy to repost it patch.\n\ncheers\n\n\nm\n"},{"id":"31198","messageId":"7vzm8ssqij.fsf@assigned-by-dhcp.cox.net","threadId":"6291","inReplyTo":"46a038f90701081839r5727c6a0qbcab1cb02dcef580@mail.gmail.com","subject":"Re: [PATCH] cvsserver: detect early of we are up to date and avoid costly rev-list","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-09T05:44:36Z","receivedAt":"2007-01-09T05:44:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Martin Langhoff\" <martin.langhoff@gmail.com> writes:\n\n> On 1/9/07, Martin Langhoff <martin@catalyst.net.nz> wrote:\n>> @@ -2194,6 +2197,10 @@ sub update\n>>      my $git_log;\n>>      my $lastcommit = $self->_get_prop(\"last_commit\");\n>>\n>> +    if ($lastcommit eq $commitsha1) { # up-to-date\n>> +         return 1;\n>> +    }\n>> +\n>>      # Start exclusive lock here...\n>>      $self->{dbh}->begin_work() or die \"Cannot lock database for BEGIN\";\n>\n> Actually, that generates a warning on the initial checkout. The fix is\n> to run the if as\n>\n>  if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date\n>\n> Junio -- is it easy for you to fixup  when you apply the patch?\n> Otherwise, I'll be happy to repost it patch.\n\nThanks but no need.  \"git commit --amend\" is our friend ;-).\n"}]}