cvsserver: cleanup extra slashes in filename arguments
Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthew Ogilvie committed
Oct 13, 2012 at 23:42 UTC
1899cbc5b2e2cb3e7c98cceed818d8adfb242ec2
1 file changed
+28
git-cvsserver.perl
+28
@@ -2309,6 +2309,9 @@ sub filenamesplit
2309
return ( $filepart, $dirpart );
2310
}
2311
2312
+# Cleanup various junk in filename (try to canonicalize it), and
2313
+# add prependdir to accomodate running CVS client from a
2314
+# subdirectory (so the output is relative to top directory of the project).
2315
sub filecleanup
2316
{
2317
my $filename = shift;
@@ -2320,11 +2323,36 @@ sub filecleanup
2323
return undef;
2324
}
2325
2326
+ if($filename eq ".")
2327
+ {
2328
+ $filename="";
2329
+ }
2330
$filename =~ s/^\.\///g;
2331
+ $filename =~ s%/+%/%g;
2332
$filename = $state->{prependdir} . $filename;
2333
+ $filename =~ s%/$%%;
2334
return $filename;
2335
}
2336
2337
+# Remove prependdir from the path, so that is is relative to the directory
2338
+# the CVS client was started from, rather than the top of the project.
2339
+# Essentially the inverse of filecleanup().
2340
+sub remove_prependdir
2341
+{
2342
+ my($path) = @_;
2343
+ if(defined($state->{prependdir}) && $state->{prependdir} ne "")
2344
+ {
2345
+ my($pre)=$state->{prependdir};
2346
+ $pre=~s%/$%%;
2347
+ if(!($path=~s%^\Q$pre\E/?%%))
2348
+ {
2349
+ $log->fatal("internal error missing prependdir");
2350
+ die("internal error missing prependdir");
2351
+ }
2352
+ }
2353
+ return $path;
2354
+}
2355
+
2356
sub validateGitDir
2357
{
2358
if( !defined($state->{CVSROOT}) )