git-branch: add -r switch to list refs/remotes/*
[git.git] / git-cvsserver.perl
index d641c03..6f10d4c 100755 (executable)
@@ -576,14 +576,15 @@ sub req_co
     # Eclipse seems to need the Clear-sticky command
     # to prepare the 'Entries' file for the new directory.
     print "Clear-sticky $checkout_path/\n";
-    print $state->{CVSROOT} . "/$checkout_path/\n";
+    print $state->{CVSROOT} . "/$module/\n";
     print "Clear-static-directory $checkout_path/\n";
-    print $state->{CVSROOT} . "/$checkout_path/\n";
+    print $state->{CVSROOT} . "/$module/\n";
 
     # instruct the client that we're checking out to $checkout_path
     print "E cvs checkout: Updating $checkout_path\n";
 
     my %seendirs = ();
+    my $lastdir ='';
 
     foreach my $git ( @{$updater->gethead} )
     {
@@ -603,15 +604,17 @@ sub req_co
             print "M U $checkout_path/$git->{name}\n";
         }
 
-       if (length($git->{dir}) && $git->{dir} ne './' && !exists($seendirs{$git->{dir}})) {
+       if (length($git->{dir}) && $git->{dir} ne './'
+           && $git->{dir} ne $lastdir && !exists($seendirs{$git->{dir}})) {
 
            # Eclipse seems to need the Clear-sticky command
            # to prepare the 'Entries' file for the new directory.
-           print "Clear-sticky $module/$git->{dir}\n";
+           print "Clear-sticky $checkout_path/$git->{dir}\n";
            print $state->{CVSROOT} . "/$module/$git->{dir}\n";
-           print "Clear-static-directory $module/$git->{dir}\n";
+           print "Clear-static-directory $checkout_path/$git->{dir}\n";
            print $state->{CVSROOT} . "/$module/$git->{dir}\n";
-           print "E cvs checkout: Updating /$module/$git->{dir}\n";
+           print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n";
+           $lastdir = $git->{dir};
            $seendirs{$git->{dir}} = 1;
        }
 
@@ -714,8 +717,27 @@ sub req_update
 
         #$log->debug("Target revision is $meta->{revision}, current working revision is $wrev");
 
-        # Files are up to date if the working copy and repo copy have the same revision, and the working copy is unmodified _and_ the user hasn't specified -C
-        next if ( defined ( $wrev ) and defined($meta->{revision}) and $wrev == $meta->{revision} and $state->{entries}{$filename}{unchanged} and not exists ( $state->{opt}{C} ) );
+        # Files are up to date if the working copy and repo copy have the same revision,
+        # and the working copy is unmodified _and_ the user hasn't specified -C
+        next if ( defined ( $wrev )
+                  and defined($meta->{revision})
+                  and $wrev == $meta->{revision}
+                  and $state->{entries}{$filename}{unchanged}
+                  and not exists ( $state->{opt}{C} ) );
+
+        # If the working copy and repo copy have the same revision,
+        # but the working copy is modified, tell the client it's modified
+        if ( defined ( $wrev )
+             and defined($meta->{revision})
+             and $wrev == $meta->{revision}
+             and not exists ( $state->{opt}{C} ) )
+        {
+            $log->info("Tell the client the file is modified");
+            print "MT text U\n";
+            print "MT fname $filename\n";
+            print "MT newline\n";
+            next;
+        }
 
         if ( $meta->{filehash} eq "deleted" )
         {
@@ -727,7 +749,8 @@ sub req_update
             print "Removed $dirpart\n";
             print "$filepart\n";
         }
-        elsif ( not defined ( $state->{entries}{$filename}{modified_hash} ) or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} )
+        elsif ( not defined ( $state->{entries}{$filename}{modified_hash} )
+               or $state->{entries}{$filename}{modified_hash} eq $oldmeta->{filehash} )
         {
             $log->info("Updating '$filename'");
             # normal update, just send the new revision (either U=Update, or A=Add, or R=Remove)
@@ -763,6 +786,7 @@ sub req_update
             # transmit file
             transmitfile($meta->{filehash});
         } else {
+            $log->info("Updating '$filename'");
             my ( $filepart, $dirpart ) = filenamesplit($meta->{name});
 
             my $dir = tempdir( DIR => $TEMP_DIR, CLEANUP => 1 ) . "/";
@@ -2328,7 +2352,7 @@ sub gethead
 
     return $self->{gethead_cache} if ( defined ( $self->{gethead_cache} ) );
 
-    my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM head",{},1);
+    my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM head ORDER BY name ASC",{},1);
     $db_query->execute();
 
     my $tree = [];