Subject: [PATCH] git-cvsserver: added support for update -p

From: Jan Wielemaker <[email-masked]>
Date: Wed, 10 Oct 2007 13:16:03 +0200

[PATCH] git-cvsserver: added support for update -p
---
Hi,

Someone in our team uses "cvs update -p [-r rev] file" (somehow invoked
through TortoiseCVS). The patch below provides that. I think it is fine,
except that I don't know with wich other flags -p can be combined and
therefore when exactly this should be tested. Figured out that normal
CVS sends the file line-by-line preceeded by "M " using strace on the
client to a real CVS server.

	Enjoy --- Jan

 git-cvsserver.perl |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 13dbd27..987f4d6 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -956,6 +956,21 @@ sub req_update
             $meta = $updater->getmeta($filename);
         }
 
+	# if we have a -p we should just send the file
+        if ( exists ( $state->{opt}{p} ) )
+	{
+	    if ( open my $fh, '-|', "git-cat-file", "blob", $meta->{filehash} )
+	    {   while ( <$fh> )
+		{ print "M " . $_;
+		}
+		close $fh or die ("Couldn't close filehandle for transmitfile(): $!");
+	    } else
+	    { die("Couldn't execute git-cat-file");
+	    }
+
+	    next;
+	}
+
 	if ( ! defined $meta )
 	{
 	    $meta = {
-- 
1.5.3.4