summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitaram Chamarty <sitaramc@gmail.com>2017-12-15 14:32:34 +0530
committerSitaram Chamarty <sitaramc@gmail.com>2017-12-15 14:52:48 +0530
commit2cfc81f230a06f629bc977baa66a149adcdbedec (patch)
tree15279884462cd4abd51b6ba1641efd1494836e28
parent3e0c51e9902ed4940b52207502ae0bb62919a79b (diff)
clean up previous patch on handling trailing slashes
Actually this is a revert of the previous patch, combined with putting that logic where it belongs (and in the process doing it more cleanly)
-rwxr-xr-xsrc/gitolite-shell20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gitolite-shell b/src/gitolite-shell
index 2f49479..072e0ff 100755
--- a/src/gitolite-shell
+++ b/src/gitolite-shell
@@ -109,10 +109,6 @@ sub main {
# set up the repo and the attempted access
my ( $verb, $repo ) = parse_soc(); # returns only for git commands
-
- # remove trailing slash, if any
- $repo =~ s(/$)();
-
Gitolite::Conf::Load::sanity($repo, $REPONAME_PATT);
$ENV{GL_REPO} = $repo;
my $aa = ( $verb =~ 'upload' ? 'R' : 'W' );
@@ -157,11 +153,19 @@ sub parse_soc {
$soc ||= 'info';
my $git_commands = "git-upload-pack|git-receive-pack|git-upload-archive";
- if ( $soc =~ m(^($git_commands) '?/?(.*?)(?:\.git(\d)?)?'?$) ) {
- my ( $verb, $repo, $trace_level ) = ( $1, $2, $3 );
- $ENV{D} = $trace_level if $trace_level;
- _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
+ # simplify the regex; we'll handle all the reponame nuances later
+ if ( $soc =~ m(^($git_commands) '?/?(.*?)'?$) ) {
+ my ( $verb, $repo ) = ( $1, $2 );
trace( 2, "git command", $soc );
+
+ # clean up the repo name; first extract the trace level if supplied
+ # (and no, you can't have a trace level *and* a trailing slash).
+ $ENV{D} = $1 if $repo =~ s/\.git(\d)$//;
+ # and then the git-daemon-compatibility trailers
+ $repo =~ s(/$)();
+ $repo =~ s(\.git$)();
+
+ _die "invalid repo name: '$repo'" if $repo !~ $REPONAME_PATT;
return ( $verb, $repo );
}