# git_get_projects_list and $projects_list

4 messages from 2006-10-31 to 2006-11-02. Participants: Aneesh Kumar, Jakub Narebski.
Thread: https://gitlist.dev/t/43296

## Aneesh Kumar, 2006-10-31 11:47

Subject: git_get_projects_list and $projects_list
Message-ID: <cc723f590610310347h58cdd69bse6d96b19479a4f6a@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590610310347h58cdd69bse6d96b19479a4f6a%40mail.gmail.com

```
Ok if i have

$projects_list = "/a/git////" ==> ending "/" . the function will fail
at check_export_ok()


That is because we get the $pfxlen wrong. We should ignore all the trailing "/"
my $subdir = substr($File::Find::name, $pfxlen + 1);



```

## Jakub Narebski, 2006-10-31 11:59

Subject: Re: git_get_projects_list and $projects_list
Message-ID: <ei7dq4$828$1@sea.gmane.org>
URL: https://gitlist.dev/e/ei7dq4%24828%241%40sea.gmane.org
In-Reply-To: <cc723f590610310347h58cdd69bse6d96b19479a4f6a@mail.gmail.com>

```
Aneesh Kumar wrote:

> Ok if i have
> 
> $projects_list = "/a/git////" ==> ending "/" . the function will fail
> at check_export_ok()
> 
> That is because we get the $pfxlen wrong. We should ignore all the trailing "/"
> my $subdir = substr($File::Find::name, $pfxlen + 1);

Perhaps it would be enough to just add 
        $dir =~ s!/+$//; 
before  
        my $pfxlen = length("$dir");
(or something equivalent). Try it and send us a patch.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Jakub Narebski, 2006-10-31 12:23

Subject: Re: git_get_projects_list and $projects_list
Message-ID: <ei7f7o$bgi$1@sea.gmane.org>
URL: https://gitlist.dev/e/ei7f7o%24bgi%241%40sea.gmane.org
In-Reply-To: <ei7dq4$828$1@sea.gmane.org>

```
Jakub Narebski wrote:

> Aneesh Kumar wrote:
> 
>> Ok if i have
>> 
>> $projects_list = "/a/git////" ==> ending "/" . the function will fail
>> at check_export_ok()
>> 
>> That is because we get the $pfxlen wrong. We should ignore all the trailing "/"
>> my $subdir = substr($File::Find::name, $pfxlen + 1);
> 
> Perhaps it would be enough to just add 
>         $dir =~ s!/+$//; 

Ooops, it should of course be

        $dir =~ s!/+$!!;

> before  
>         my $pfxlen = length("$dir");
> (or something equivalent). Try it and send us a patch.


-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Aneesh Kumar, 2006-11-02 04:13

Subject: Re: git_get_projects_list and $projects_list
Message-ID: <cc723f590611012013v1359efb9qdb5888fc458da22@mail.gmail.com>
URL: https://gitlist.dev/e/cc723f590611012013v1359efb9qdb5888fc458da22%40mail.gmail.com
In-Reply-To: <ei7f7o$bgi$1@sea.gmane.org>

```
On 10/31/06, Jakub Narebski <jnareb@gmail.com> wrote:

>         $dir =~ s!/+$!!;
>

That works. Attaching the diff below

-aneesh


diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index bf5f829..4343450 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -897,6 +897,8 @@ sub git_get_projects_list {
 	if (-d $projects_list) {
 		# search in directory
 		my $dir = $projects_list;
+		# remove the trailing "/"
+		$dir =~ s!/+$!!;
 		my $pfxlen = length("$dir");
 
 		File::Find::find({

```
