Hi, this is the patch to limit repositories to be shown by the ServerName in the gitweb.cgi script. This is useful for cases you're hosting multiple websites on a single machine and you don't want all the repos to be shown in all of them. Functionality: Simply create file called 'server' in the git repository (the same location like for 'description' file) and put the server name to show this repo for. Testing: It's been tested on a test server and everything was working fine/as expected. If there's no 'server' file in the git repository it falls back to the default option to show the repository as it was working before this patch applied not to introduce any regressive behaviour. Use case scenario: Imagine you have one server running HTTPd for 3 domains, let's call them domain1, domain2 and domain3, and you want all of them to have a git server accessible via gitweb at these URLs: 1) http://domain1/git 2) http://domain2/git 3) http://domain3/git Before this patch, all the URLs would be showing the same repos however we would like to limit repo1 to be shown only on domain1, repo2 to be shown only on domain2 and repo3 to be shown only on domain3. Here my patch comes handy because you simply edit the 'repo1/server' file and put 'domain1' in here and it won't get shown on any other URL. The same for repo2 and repo3 and it will be shown only for the domain it belongs to. Also, if no 'server' file exists in the repo the repository is being shown so upgrading gitweb with no creation of 'server' files will preserve the old behaviour. Hope this will help, at least it did help me on my test server. Any feedback appreciated! Thanks, Michal Signed-off-by: Michal Novotny <minovotn@xxxxxxxxxx> --- gitweb/gitweb.perl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 3d6a705..1b74239 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2804,6 +2804,11 @@ sub git_get_project_description { return git_get_file_or_project_config($path, 'description'); } +sub git_get_project_server { + my $path = shift; + return git_get_file_or_project_config($path, 'server'); +} + sub git_get_project_category { my $path = shift; return git_get_file_or_project_config($path, 'category'); @@ -2947,6 +2952,19 @@ sub git_get_project_url_list { return wantarray ? @git_project_url_list : \@git_project_url_list; } +sub get_project_can_export { + my ($path) = @_; + + if (defined $ENV{'SERVER_NAME'}) { + my $server = git_get_project_server($path) || ""; + + return (($server eq $ENV{'SERVER_NAME'}) or ($server eq '')); + } + else { + return 1; + } +} + sub git_get_projects_list { my $filter = shift || ''; my $paranoid = shift; @@ -2990,7 +3008,8 @@ sub git_get_projects_list { next; } # we check related file in $projectroot - if (check_export_ok("$projectroot/$path")) { + if (check_export_ok("$projectroot/$path") and + get_project_can_export($path)) { push @list, { path => $path }; $File::Find::prune = 1; } @@ -3016,7 +3035,8 @@ sub git_get_projects_list { if ($filter && $path !~ m!^\Q$filter\E/!) { next; } - if (check_export_ok("$projectroot/$path")) { + if (check_export_ok("$projectroot/$path") and + get_project_can_export($path)) { my $pr = { path => $path }; -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html