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

[PATCH] cvsserver: Allow to "add" a removed file

From
Frank Lichtenheld <frank@lichtenheld.de>
Date
Apr 11, 2007, 22:51 UTC
Message-ID
<11763318932426-git-send-email-frank@lichtenheld.de>

CVS allows you to add a removed file (where the removal is not yet committed) which will cause the server to send the latest revision of the file and to delete the "removed" status.

Copy this behaviour.
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
 git-cvsserver.perl |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
 Something I noted during my regression tests for my previous
 patch.
 Note: if you added back the file prior to calling 'cvs add'
 you will get a
 cvs add: move away `./testfile'; it is in the way
 C testfile
 which is not exactly what the original CVS does:
 cvs add: `testfile' should be removed and is still there (or is back again)
 but near enough so that I didn't care much about recreating
 that part yet.
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 25816c5..eeadf3d 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -350,12 +350,52 @@ sub req_add
 
     argsplit("add");
 
+    my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
+    $updater->update();
+
+    argsfromdir($updater);
+
     my $addcount = 0;
 
     foreach my $filename ( @{$state->{args}} )
     {
         $filename = filecleanup($filename);
 
+        my $meta = $updater->getmeta($filename);
+        my $wrev = revparse($filename);
+
+        if ($wrev && $meta && ($wrev < 0))
+        {
+            # previously removed file, add back
+            $log->info("added file $filename was previously removed, send 1.$meta->{revision}");
+
+            print "MT +updated\n";
+            print "MT text U \n";
+            print "MT fname $filename\n";
+            print "MT newline\n";
+            print "MT -updated\n";
+
+            unless ( $state->{globaloptions}{-n} )
+            {
+                my ( $filepart, $dirpart ) = filenamesplit($filename,1);
+
+                print "Created $dirpart\n";
+                print $state->{CVSROOT} . "/$state->{module}/$filename\n";
+
+                # this is an "entries" line
+                my $kopts = kopts_from_path($filepart);
+                $log->debug("/$filepart/1.$meta->{revision}//$kopts/");
+                print "/$filepart/1.$meta->{revision}//$kopts/\n";
+                # permissions
+                $log->debug("SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}");
+                print "u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\n";
+                # transmit file
+                transmitfile($meta->{filehash});
+            }
+
+            next;
+        }
+
         unless ( defined ( $state->{entries}{$filename}{modified_filename} ) )
         {
             print "E cvs add: nothing known about `$filename'\n";
-- 
1.5.1
Message 1 of 1 in “cvsserver: Allow to "add" a removed file”
  1. cvsserver: Allow to "add" a removed fileFrank Lichtenheld, Apr 11, 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.