Skip to contentSkip to conversation

gitweb: Remove extra "/" in path names for git_get_project_list

PATCH In review Aneesh Kumar K.V 3 participants 3 messages Aug 11, 2016

lore
Share & tools
lore
#2 lore raw
In reply to Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · Aneesh Kumar K.V

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

Quoted 8 lines
Quoted 3 lines

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

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

Quoted 2 lines
gitweb/gitweb.perl +2 -0
+            # remove the trailing "/"
+            $dir =~ s!/+$!!;

So perhaps

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

(zero-width positive look-behind assertion).

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#1 lore raw
In reply to Aneesh Kumar K.V
Quoted 7 lines · Aneesh Kumar K.V

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/";

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

Quoted 2 lines
gitweb/gitweb.perl +2 -0
+		# remove the trailing "/"
+		$dir =~ s!/+$!!;
#0 lore raw

PATCH 1/1 gitweb: Remove extra "/" in path names for git_get_project_list

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/";

---
 gitweb/gitweb.perl |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +2 -0
index 7710cc2..a0a9aaf 100755
@@ -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({
Signature · 1 line
1.4.3.3.gc954-dirty