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";
38 our $repo_regexp= '^(\\w[-+._0-9A-Za-z]*/?\.git)$'; # stupid emacs ';
41 our ($serve_user, $serve_dir, $serve_repo);
46 -f _ or fail "bad config $_ - not a file";
49 $!==&ENOENT or fail "bad config $_ - could not stat: $!";
54 @ARGV = grep { fexists($_) } @ARGV;
63 if (m{^ single-user \s+ (\S+?) (/\S*)? \s+ (\S+) (?: \s+ (\S+) )? $ }x) {
64 my ($h,$v,$u,$d) = ($1,$2,$3,$4);
65 next unless $h eq $spechost;
66 $serve_repo= remain_path($v);
67 next unless defined $serve_repo;
70 syslog 'debug', "DEBUG $ARGV:$. match".
71 " $serve_user $serve_dir $serve_repo";
72 } elsif (m{^ multi-user \s+ (\S+?) (/\S*)? \s+ (\S+) $ }x) {
73 my ($h,$v,$d) = ($1,$2,$3);
74 next unless $1 eq $spechost;
75 $serve_repo= remain_path($v);
76 next unless defined $serve_repo;
77 syslog 'debug', "DEBUG $ARGV:$. perhaps $serve_repo";
78 next unless $serve_repo =~ s{ ^/\~( [a-z][-+_0-9a-z]* )/ }{/}xi;
81 syslog 'debug', "DEBUG $ARGV:$. match".
82 " $serve_user $serve_dir $serve_repo";
83 } elsif (m{^ repo-regexp \s+ (\S.*) $ }x) {
85 } elsif (m{^ (no-)?require-git-daemon-export-ok $ }x) {
86 $check_export= !defined $1;
88 fail "config syntax error at $ARGV:$.";