{"thread":{"id":"5878","subject":"[PATCH] cvsserver: Show correct letters for modified, removed and added files","startedAt":"2006-10-10T22:20:43Z","lastAt":"2006-10-10T22:20:43Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"28564","messageId":"Pine.LNX.4.63.0610110019400.14200@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"5878","inReplyTo":null,"subject":"[PATCH] cvsserver: Show correct letters for modified, removed and added files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-10-10T22:20:43Z","receivedAt":"2006-10-10T22:20:43Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nEarlier, cvsserver showed always an 'U', sometimes even without a space\nbetween the 'U' and the name. Now, the correct letter is shown, with a\nspace.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n git-cvsserver.perl |   63 ++++++++++++++++++++++++++++++++++++++++++----------\n 1 files changed, 51 insertions(+), 12 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 2c1b0c7..7260f32 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -807,7 +807,14 @@ sub req_update\n             $meta = $updater->getmeta($filename);\n         }\n \n-        next unless ( $meta->{revision} );\n+\tif ( ! defined $meta )\n+\t{\n+\t    $meta = {\n+\t        name => $filename,\n+\t        revision => 0,\n+\t        filehash => 'added'\n+\t    };\n+\t}\n \n         my $oldmeta = $meta;\n \n@@ -837,7 +844,7 @@ sub req_update\n              and not exists ( $state->{opt}{C} ) )\n         {\n             $log->info(\"Tell the client the file is modified\");\n-            print \"MT text U\\n\";\n+            print \"MT text M \\n\";\n             print \"MT fname $filename\\n\";\n             print \"MT newline\\n\";\n             next;\n@@ -857,15 +864,36 @@ sub req_update\n \t    }\n         }\n         elsif ( not defined ( $state->{entries}{$filename}{modified_hash} )\n-\t\tor $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} )\n+\t\tor $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash}\n+\t\tor $meta->{filehash} eq 'added' )\n         {\n-            $log->info(\"Updating '$filename'\");\n-            # normal update, just send the new revision (either U=Update, or A=Add, or R=Remove)\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+            # normal update, just send the new revision (either U=Update,\n+            # or A=Add, or R=Remove)\n+\t    if ( defined($wrev) && $wrev < 0 )\n+\t    {\n+\t        $log->info(\"Tell the client the file is scheduled for removal\");\n+\t\tprint \"MT text R \\n\";\n+                print \"MT fname $filename\\n\";\n+                print \"MT newline\\n\";\n+\t\tnext;\n+\t    }\n+\t    elsif ( !defined($wrev) || $wrev == 0 )\n+\t    {\n+\t        $log->info(\"Tell the client the file will be added\");\n+\t\tprint \"MT text A \\n\";\n+                print \"MT fname $filename\\n\";\n+                print \"MT newline\\n\";\n+\t\tnext;\n+\n+\t    }\n+\t    else {\n+                $log->info(\"Updating '$filename' $wrev\");\n+                print \"MT +updated\\n\";\n+                print \"MT text U \\n\";\n+                print \"MT fname $filename\\n\";\n+                print \"MT newline\\n\";\n+\t\tprint \"MT -updated\\n\";\n+\t    }\n \n             my ( $filepart, $dirpart ) = filenamesplit($filename,1);\n \n@@ -1711,6 +1739,17 @@ sub argsfromdir\n \n     return if ( scalar ( @{$state->{args}} ) > 1 );\n \n+    my @gethead = @{$updater->gethead};\n+\n+    # push added files\n+    foreach my $file (keys %{$state->{entries}}) {\n+    \tif ( exists $state->{entries}{$file}{revision} &&\n+\t\t$state->{entries}{$file}{revision} == 0 )\n+\t{\n+\t    push @gethead, { name => $file, filehash => 'added' };\n+\t}\n+    }\n+\n     if ( scalar(@{$state->{args}}) == 1 )\n     {\n         my $arg = $state->{args}[0];\n@@ -1718,7 +1757,7 @@ sub argsfromdir\n \n         $log->info(\"Only one arg specified, checking for directory expansion on '$arg'\");\n \n-        foreach my $file ( @{$updater->gethead} )\n+        foreach my $file ( @gethead )\n         {\n             next if ( $file->{filehash} eq \"deleted\" and not defined ( $state->{entries}{$file->{name}} ) );\n             next unless ( $file->{name} =~ /^$arg\\// or $file->{name} eq $arg  );\n@@ -1731,7 +1770,7 @@ sub argsfromdir\n \n         $state->{args} = [];\n \n-        foreach my $file ( @{$updater->gethead} )\n+        foreach my $file ( @gethead )\n         {\n             next if ( $file->{filehash} eq \"deleted\" and not defined ( $state->{entries}{$file->{name}} ) );\n             next unless ( $file->{name} =~ s/^$state->{prependdir}// );\n-- \n1.4.3.rc2.g35de\n"}]}