{"thread":{"id":"7617","subject":"[PATCH] cvsserver: Allow to \"add\" a removed file","startedAt":"2007-04-11T22:51:33Z","lastAt":"2007-04-11T22:51:33Z","messageCount":1,"participants":["Frank Lichtenheld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39150","messageId":"11763318932426-git-send-email-frank@lichtenheld.de","threadId":"7617","inReplyTo":null,"subject":"[PATCH] cvsserver: Allow to \"add\" a removed file","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-04-11T22:51:33Z","receivedAt":"2007-04-11T22:51:33Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"CVS allows you to add a removed file (where the\nremoval is not yet committed) which will\ncause the server to send the latest revision of the\nfile and to delete the \"removed\" status.\n\nCopy this behaviour.\n\nSigned-off-by: Frank Lichtenheld <frank@lichtenheld.de>\n---\n git-cvsserver.perl |   40 ++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 40 insertions(+), 0 deletions(-)\n\n Something I noted during my regression tests for my previous\n patch.\n\n Note: if you added back the file prior to calling 'cvs add'\n you will get a\n\n cvs add: move away `./testfile'; it is in the way\n C testfile\n\n which is not exactly what the original CVS does:\n\n cvs add: `testfile' should be removed and is still there (or is back again)\n\n but near enough so that I didn't care much about recreating\n that part yet.\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 25816c5..eeadf3d 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -350,12 +350,52 @@ sub req_add\n \n     argsplit(\"add\");\n \n+    my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);\n+    $updater->update();\n+\n+    argsfromdir($updater);\n+\n     my $addcount = 0;\n \n     foreach my $filename ( @{$state->{args}} )\n     {\n         $filename = filecleanup($filename);\n \n+        my $meta = $updater->getmeta($filename);\n+        my $wrev = revparse($filename);\n+\n+        if ($wrev && $meta && ($wrev < 0))\n+        {\n+            # previously removed file, add back\n+            $log->info(\"added file $filename was previously removed, send 1.$meta->{revision}\");\n+\n+            print \"MT +updated\\n\";\n+            print \"MT text U \\n\";\n+            print \"MT fname $filename\\n\";\n+            print \"MT newline\\n\";\n+            print \"MT -updated\\n\";\n+\n+            unless ( $state->{globaloptions}{-n} )\n+            {\n+                my ( $filepart, $dirpart ) = filenamesplit($filename,1);\n+\n+                print \"Created $dirpart\\n\";\n+                print $state->{CVSROOT} . \"/$state->{module}/$filename\\n\";\n+\n+                # this is an \"entries\" line\n+                my $kopts = kopts_from_path($filepart);\n+                $log->debug(\"/$filepart/1.$meta->{revision}//$kopts/\");\n+                print \"/$filepart/1.$meta->{revision}//$kopts/\\n\";\n+                # permissions\n+                $log->debug(\"SEND : u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\");\n+                print \"u=$meta->{mode},g=$meta->{mode},o=$meta->{mode}\\n\";\n+                # transmit file\n+                transmitfile($meta->{filehash});\n+            }\n+\n+            next;\n+        }\n+\n         unless ( defined ( $state->{entries}{$filename}{modified_filename} ) )\n         {\n             print \"E cvs add: nothing known about `$filename'\\n\";\n-- \n1.5.1\n"}]}