4 # $specpath whole path from caller, minus any leading /s
5 # $spechost host from caller
12 # if match found for this host and path:
13 # $serve_user username, or undef if no match (then other serve_* invalid)
14 # $serve_dir directory as specified in config
15 # $serve_repo subpath under $serve_dir _including_ leading /
17 # for use by user's service program
22 # return value matches {( / [^/]+ )+}x
24 syslog 'debug', sprintf "DEBUG remain_path %s $specpath",
25 (defined $vsubpath ? $vsubpath : '<undef>');
26 return "/$specpath" if !defined $vsubpath;
27 return "" if $vsubpath eq $specpath;
28 return substr($specpath,length($vsubpath))
29 if substr($specpath,0,length($vsubpath)+1) eq "$vsubpath/";
33 fail "no config ??" unless @ARGV;
34 fail "no specpath ??" unless length $specpath;
36 our $uri = "git://$spechost/$specpath";
37 our $repo_regexp= '^/*(\\w[-+._0-9A-Za-z]*)$'; # stupid emacs ';
40 our ($serve_user, $serve_dir, $serve_repo);
45 -f _ or fail "bad config $_ - not a file";
48 $!==&ENOENT or fail "bad config $_ - could not stat: $!";
53 @ARGV = grep { fexists($_) } @ARGV;
62 if (m{^ single-user \s+ (\S+?) (/\S*)? \s+ (\S+) (?: \s+ (\S+) )? $ }x) {
63 my ($h,$v,$u,$d) = ($1,$2,$3,$4);
64 next unless $h eq $spechost;
65 $serve_repo= remain_path($v);
66 next unless defined $serve_repo;
69 syslog 'debug', "DEBUG $ARGV:$. match".
70 " $serve_user $serve_dir $serve_repo";
71 } elsif (m{^ multi-user \s+ (\S+?) (/\S*)? \s+ (\S+) $ }x) {
72 my ($h,$v,$d) = ($1,$2,$3);
73 next unless $1 eq $spechost;
74 $serve_repo= remain_path($v);
75 next unless defined $serve_repo;
76 syslog 'debug', "DEBUG $ARGV:$. perhaps $serve_repo";
77 next unless $serve_repo =~ s{ ^/\~( [a-z][-+_0-9a-z]* )/ }{/}xi;
80 syslog 'debug', "DEBUG $ARGV:$. match".
81 " $serve_user $serve_dir $serve_repo";
82 } elsif (m{^ repo-regexp \s+ (\S.*) $ }x) {
84 } elsif (m{^ (no-)?require-git-daemon-export-ok $ }x) {
85 $check_export= !defined $1;
87 fail "config syntax error at $ARGV:$.";