# Re: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list

3 messages from 2006-11-03 to 2006-11-03. Participants: Jakub Narebski, Junio C Hamano, Aneesh Kumar K.V.
Thread: https://gitlist.dev/t/43523

## Aneesh Kumar K.V, 2006-11-03 05:11

Subject: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list
Message-ID: <454ACF91.50601@gmail.com>
URL: https://gitlist.dev/e/454ACF91.50601%40gmail.com

```



Without this change we get a wrong $pfxlen value and the check_export_ok()
checks with with a wrong directory name. Without this patch the below
$projects_list fails with gitweb

$projects_list = "/tmp/a/b/";

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
---
 gitweb/gitweb.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7710cc2..a0a9aaf 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({
-- 
1.4.3.3.gc954-dirty


```

## Junio C Hamano, 2006-11-03 05:59

Subject: Re: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list
Message-ID: <7vslh1jcji.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vslh1jcji.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <454ACF91.50601@gmail.com>

```
"Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:

> Without this change we get a wrong $pfxlen value and the check_export_ok()
> checks with with a wrong directory name. Without this patch the below
> $projects_list fails with gitweb
>
> $projects_list = "/tmp/a/b/";
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

Hmph.  Doesn't this break $projects_list = "/", I wonder?

> +		# remove the trailing "/"
> +		$dir =~ s!/+$!!;


```

## Jakub Narebski, 2006-11-03 11:18

Subject: Re: [PATCH] gitweb: Remove extra "/" in path names for git_get_project_list
Message-ID: <eif8gd$6u5$1@sea.gmane.org>
URL: https://gitlist.dev/e/eif8gd%246u5%241%40sea.gmane.org
In-Reply-To: <7vslh1jcji.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> "Aneesh Kumar K.V" <aneesh.kumar@gmail.com> writes:
> 
>> Without this change we get a wrong $pfxlen value and the check_export_ok()
>> checks with with a wrong directory name. Without this patch the below
>> $projects_list fails with gitweb
>>
>> $projects_list = "/tmp/a/b/";
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>
> 
> Hmph.  Doesn't this break $projects_list = "/", I wonder?
> 
>> +            # remove the trailing "/"
>> +            $dir =~ s!/+$!!;

So perhaps

        $dir =~ s!(?<=[^/])/+$!!;

(zero-width positive look-behind assertion).
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```
