Skip to content

Commit 1899cbc

Browse files
Matthew Ogilviegitster
authored andcommitted
cvsserver: cleanup extra slashes in filename arguments
Signed-off-by: Matthew Ogilvie <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2c3af7e commit 1899cbc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

git-cvsserver.perl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,9 @@ sub filenamesplit
23092309
return ( $filepart, $dirpart );
23102310
}
23112311

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).
23122315
sub filecleanup
23132316
{
23142317
my $filename = shift;
@@ -2320,11 +2323,36 @@ sub filecleanup
23202323
return undef;
23212324
}
23222325

2326+
if($filename eq ".")
2327+
{
2328+
$filename="";
2329+
}
23232330
$filename =~ s/^\.\///g;
2331+
$filename =~ s%/+%/%g;
23242332
$filename = $state->{prependdir} . $filename;
2333+
$filename =~ s%/$%%;
23252334
return $filename;
23262335
}
23272336

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+
23282356
sub validateGitDir
23292357
{
23302358
if( !defined($state->{CVSROOT}) )

0 commit comments

Comments
 (0)