[PATCH] Calculate $commitsha1 in update() only when needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This suppresses unhelpful error messages from git rev-parse during
checkout if the module doesn't exist.

Signed-off-by: Pavel Roskin <proski@xxxxxxx>
---

 git-cvsserver.perl |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index ecded3b..409b301 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -2427,9 +2427,6 @@ sub update
     # first lets get the commit list
     $ENV{GIT_DIR} = $self->{git_path};
 
-    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}/ )
     {
@@ -2440,8 +2437,13 @@ sub update
     my $git_log;
     my $lastcommit = $self->_get_prop("last_commit");
 
-    if (defined $lastcommit && $lastcommit eq $commitsha1) { # up-to-date
-         return 1;
+    if (defined $lastcommit) {
+        my $commitsha1 = `git rev-parse $self->{module}`;
+        chomp $commitsha1;
+
+        if ($lastcommit eq $commitsha1) { # up-to-date
+            return 1;
+        }
     }
 
     # Start exclusive lock here...
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux