Code

Merge branch 'gp/maint-cvsserver'
authorJunio C Hamano <gitster@pobox.com>
Thu, 28 Jan 2010 08:46:33 +0000 (00:46 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Jan 2010 08:46:33 +0000 (00:46 -0800)
* gp/maint-cvsserver:
  git-cvsserver: allow regex metacharacters in CVSROOT

1  2 
git-cvsserver.perl

diff --combined git-cvsserver.perl
index 28041060c8a36ac2b89ee179501c2ec726f4606b,046f5578a11f2d0dc5326b4b4593b0093f006b15..13751db882dd2c40e2c78503eba0d3f941297644
@@@ -104,7 -104,6 +104,7 @@@ $log->info("--------------- STARTING --
  my $usage =
      "Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
      "    --base-path <path>  : Prepend to requested CVSROOT\n".
 +    "                          Can be read from GIT_CVSSERVER_BASE_PATH\n".
      "    --strict-paths      : Don't allow recursing into subdirectories\n".
      "    --export-all        : Don't check for gitcvs.enabled in config\n".
      "    --version, -V       : Print version information and exit\n".
      "\n".
      "<directory> ... is a list of allowed directories. If no directories\n".
      "are given, all are allowed. This is an additional restriction, gitcvs\n".
 -    "access still needs to be enabled by the gitcvs.enabled config option.\n";
 +    "access still needs to be enabled by the gitcvs.enabled config option.\n".
 +    "Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\n";
  
  my @opts = ( 'help|h|H', 'version|V',
             'base-path=s', 'strict-paths', 'export-all' );
@@@ -150,24 -148,6 +150,24 @@@ if ($state->{'export-all'} && !@{$state
      die "--export-all can only be used together with an explicit whitelist\n";
  }
  
 +# Environment handling for running under git-shell
 +if (exists $ENV{GIT_CVSSERVER_BASE_PATH}) {
 +    if ($state->{'base-path'}) {
 +      die "Cannot specify base path both ways.\n";
 +    }
 +    my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};
 +    $state->{'base-path'} = $base_path;
 +    $log->debug("Picked up base path '$base_path' from environment.\n");
 +}
 +if (exists $ENV{GIT_CVSSERVER_ROOT}) {
 +    if (@{$state->{allowed_roots}}) {
 +      die "Cannot specify roots both ways: @ARGV\n";
 +    }
 +    my $allowed_root = $ENV{GIT_CVSSERVER_ROOT};
 +    $state->{allowed_roots} = [ $allowed_root ];
 +    $log->debug("Picked up allowed root '$allowed_root' from environment.\n");
 +}
 +
  # if we are called with a pserver argument,
  # deal with the authentication cat before entering the
  # main loop
@@@ -408,7 -388,7 +408,7 @@@ sub req_Director
      $state->{localdir} = $data;
      $state->{repository} = $repository;
      $state->{path} = $repository;
-     $state->{path} =~ s/^$state->{CVSROOT}\///;
+     $state->{path} =~ s/^\Q$state->{CVSROOT}\E\///;
      $state->{module} = $1 if ($state->{path} =~ s/^(.*?)(\/|$)//);
      $state->{path} .= "/" if ( $state->{path} =~ /\S/ );
  
@@@ -1001,8 -981,6 +1001,8 @@@ sub req_updat
  
      #$log->debug("update state : " . Dumper($state));
  
 +    my $last_dirname = "///";
 +
      # foreach file specified on the command line ...
      foreach my $filename ( @{$state->{args}} )
      {
  
          $log->debug("Processing file $filename");
  
 +        unless ( $state->{globaloptions}{-Q} || $state->{globaloptions}{-q} )
 +        {
 +            my $cur_dirname = dirname($filename);
 +            if ( $cur_dirname ne $last_dirname )
 +            {
 +                $last_dirname = $cur_dirname;
 +                if ( $cur_dirname eq "" )
 +                {
 +                    $cur_dirname = ".";
 +                }
 +                print "E cvs update: Updating $cur_dirname\n";
 +            }
 +        }
 +
          # if we have a -C we should pretend we never saw modified stuff
          if ( exists ( $state->{opt}{C} ) )
          {