threads / patch / 16719

patch, 2 partsgitweb: allow access to forks with strict_export

Subject: [PATCH 1/2] gitweb: allow access to forks with strict_export

## tl;dr

7 messages between Dec 13, 2008 and Dec 20, 2008. Diffs are folded; open one to read it.

replies: 6people: 3as markdown or json

Matt McCutchen· Dec 13, 2008, 21:16 UTC · lore

git_get_projects_list excludes forks in order to unclutter the main project list, but this caused the strict_export check, which also relies on git_get_project_list, to incorrectly fail for forks. This patch adds an argument so git_get_projects_list knows when it is being called for a strict_export check (as opposed to a user-visible project list) and doesn't exclude the forks.

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
---
 gitweb/gitweb.perl |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
Show changes to gitweb/gitweb.perl +4 −3
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 86511cf..5357bcc 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1144,7 +1144,8 @@ sub untabify {
 
 sub project_in_list {
 	my $project = shift;
-	my @list = git_get_projects_list();
+	# Tell git_get_projects_list to include forks.
+	my @list = git_get_projects_list(undef, 1);
 	return @list && scalar(grep { $_->{'path'} eq $project } @list);
 }
 
@@ -2128,13 +2129,13 @@ sub git_get_project_url_list {
 }
 
 sub git_get_projects_list {
-	my ($filter) = @_;
+	my ($filter, $for_strict_export) = @_;
 	my @list;
 
 	$filter ||= '';
 	$filter =~ s/\.git$//;
 
-	my $check_forks = gitweb_check_feature('forks');
+	my $check_forks = !$for_strict_export && gitweb_check_feature('forks');
 
 	if (-d $projects_list) {
 		# search in directory
-- 
1.6.1.rc2.27.gc7114
Jakub Narebski· Dec 13, 2008, 21:53 UTC · re: Matt McCutchen · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

Matt McCutchen <matt@mattmccutchen.net> writes:
CC-ed Petr Baudis, author of forks support in gitweb.
Show 8 quoted lines
> git_get_projects_list excludes forks in order to unclutter the main
> project list, but this caused the strict_export check, which also relies
> on git_get_project_list, to incorrectly fail for forks.  This patch adds
> an argument so git_get_projects_list knows when it is being called for a
> strict_export check (as opposed to a user-visible project list) and
> doesn't exclude the forks.
> 
> Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Looks good for me.
Acked-by: Jakub Narebski <jnareb@gmail.com>
Show 38 quoted lines
> ---
>  gitweb/gitweb.perl |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 86511cf..5357bcc 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -1144,7 +1144,8 @@ sub untabify {
>  
>  sub project_in_list {
>  	my $project = shift;
> -	my @list = git_get_projects_list();
> +	# Tell git_get_projects_list to include forks.
> +	my @list = git_get_projects_list(undef, 1);
>  	return @list && scalar(grep { $_->{'path'} eq $project } @list);
>  }
>  
> @@ -2128,13 +2129,13 @@ sub git_get_project_url_list {
>  }
>  
>  sub git_get_projects_list {
> -	my ($filter) = @_;
> +	my ($filter, $for_strict_export) = @_;
>  	my @list;
>  
>  	$filter ||= '';
>  	$filter =~ s/\.git$//;
>  
> -	my $check_forks = gitweb_check_feature('forks');
> +	my $check_forks = !$for_strict_export && gitweb_check_feature('forks');
>  
>  	if (-d $projects_list) {
>  		# search in directory
> -- 
> 1.6.1.rc2.27.gc7114
> 
> 
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Junio C Hamano· Dec 13, 2008, 22:31 UTC · re: Jakub Narebski · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

Jakub Narebski <jnareb@gmail.com> writes:
Show 14 quoted lines
> Matt McCutchen <matt@mattmccutchen.net> writes:
>
> CC-ed Petr Baudis, author of forks support in gitweb.
>
>> git_get_projects_list excludes forks in order to unclutter the main
>> project list, but this caused the strict_export check, which also relies
>> on git_get_project_list, to incorrectly fail for forks.  This patch adds
>> an argument so git_get_projects_list knows when it is being called for a
>> strict_export check (as opposed to a user-visible project list) and
>> doesn't exclude the forks.
>>
>> Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
>
> Looks good for me.
That sounds like a broken API to me.

At least, please have the decency to not call the extra parameter "for strict export". I would understand it if the extra parameter is called "toplevel_only" (or its negation, "include_forks").

IOW, don't name a parameter after the name of one caller that happens to want an unspecified special semantics, without saying what that special semantics is. Instead, name it after the special semantics that the argument triggers.

Jakub Narebski· Dec 13, 2008, 22:51 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

Junio C Hamano wrote:
Show 26 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> > Matt McCutchen <matt@mattmccutchen.net> writes:
>>
>> CC-ed Petr Baudis, author of forks support in gitweb.
>>
>>> git_get_projects_list excludes forks in order to unclutter the main
>>> project list, but this caused the strict_export check, which also relies
>>> on git_get_project_list, to incorrectly fail for forks.  This patch adds
>>> an argument so git_get_projects_list knows when it is being called for a
>>> strict_export check (as opposed to a user-visible project list) and
>>> doesn't exclude the forks.
>>>
>>> Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
>>
>> Looks good for me.
> 
> That sounds like a broken API to me.
> 
> At least, please have the decency to not call the extra parameter "for
> strict export".  I would understand it if the extra parameter is called
> "toplevel_only" (or its negation, "include_forks").
> 
> IOW, don't name a parameter after the name of one caller that happens to
> want an unspecified special semantics, without saying what that special
> semantics is.  Instead, name it after the special semantics that the
> argument triggers.
 
Ahhh... true. 

"no_hide" (currently "include_forks") allows us to _not_ passing this parameter in other places than project_in_list(); undef is falsy.

By the way, doesn't git_project_index and perhaps git_opml also need this parameter passed to git_get_projects_list?

Then patch subject would change...
-- 
Jakub Narebski
Poland
Matt McCutchen· Dec 14, 2008, 02:06 UTC · re: Jakub Narebski · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

On Sat, 2008-12-13 at 23:51 +0100, Jakub Narebski wrote:
> "no_hide" (currently "include_forks") allows us to _not_ passing this
> parameter in other places than project_in_list(); undef is falsy.

Right. That's why I made the current parameter $for_strict_export (so only project_in_list passes it) rather than the negation.

> By the way, doesn't git_project_index and perhaps git_opml also need
> this parameter passed to git_get_projects_list?

Yes, now that you mention it, I suppose they should show forks, though not hidden repositories. Then git_get_projects_list can be called in three different modes: include everything (project_in_list), include forks but not hidden (git_get_project_index and git_opml), or include neither forks nor hidden (git_project_list). Should we have two separate parameters to git_get_projects_list or a single three-valued one?

That raises another point. I was going to change git_get_projects_list so that forks of a hidden project that are not themselves hidden appear on the parent project's page but not in the main project list. This way, users who know about the parent project can navigate to the fork, but the fork does not give away the existence of the parent project by appearing in the main list. Then I guess git_project_index and git_opml should omit forks of hidden projects, meaning that some fork-checking still has to take place with "include forks" on but "include hidden" off. This will make git_get_projects_list somewhat more complex but not unmanageably so, and I do think it's the behavior we want.

I will send an updated patch.
-- 
Matt
Jakub Narebski· Dec 20, 2008, 00:35 UTC · re: Matt McCutchen · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

On Sun, 14 Dec 2008 03:06, Matt McCutchen napisał:
Show 7 quoted lines
> On Sat, 2008-12-13 at 23:51 +0100, Jakub Narebski wrote:
> >
> > "no_hide" (currently "include_forks") allows us to _not_ passing this
> > parameter in other places than project_in_list(); undef is falsy.
> 
> Right.  That's why I made the current parameter $for_strict_export (so
> only project_in_list passes it) rather than the negation.

Still I think $for_strict_export is singularly _bad_ name for a parameter. $no_hide or $show_all would be much, much better.

Show 10 quoted lines
> > By the way, doesn't git_project_index and perhaps git_opml also need
> > this parameter passed to git_get_projects_list?
> 
> Yes, now that you mention it, I suppose they should show forks, though
> not hidden repositories.  Then git_get_projects_list can be called in
> three different modes: include everything (project_in_list), include
> forks but not hidden (git_get_project_index and git_opml), or include
> neither forks nor hidden (git_project_list).  Should we have two
> separate parameters to git_get_projects_list or a single three-valued
> one?

By the way, I am not sure if your idea of "hidden projects" and projects list (projects index) file.

We have two way of specifying list of projects. One is scanning projectroot directory for something that looks like git repository, the other is having projects list file with project paths and project owners.

If you use projects list file, you can have projects which are in not on project list, but are accessible in filesystem. Those projects (repositories) are hidden, i.e. they are not visible on projects_list page, but still you can access a project. If you want to have projects which are not on list to be not accessible at all, and not only hidden, you have to use $strict_export... using which makes access to repo views a tiny bit slower (and _only_ slows down gitweb for when scanning directories for projects).

But why would one _want_ projects which are not visible, but still accessible; "hidden" projects? Moreso what you want, the three class of projects inside $projectroot: visible, hidden, and not exported.

With newly added $export_auth_hook you can limit accessibility of projects in other ways, for example using .htaccess control files of Apache web server. Check gitweb/README (or gitweb/INSTALL) for example.

Show 12 quoted lines
> That raises another point.  I was going to change git_get_projects_list
> so that forks of a hidden project that are not themselves hidden appear
> on the parent project's page but not in the main project list.  This
> way, users who know about the parent project can navigate to the fork,
> but the fork does not give away the existence of the parent project by
> appearing in the main list.  Then I guess git_project_index and git_opml
> should omit forks of hidden projects, meaning that some fork-checking
> still has to take place with "include forks" on but "include hidden"
> off.  This will make git_get_projects_list somewhat more complex but not
> unmanageably so, and I do think it's the behavior we want.
> 
> I will send an updated patch.

So you see that having explicitly hidden files have yet another complication. I wonder if this is really worth it...

-- 
Jakub Narebski
Poland
Matt McCutchen· Dec 14, 2008, 01:51 UTC · re: Junio C Hamano · lore

Re: [PATCH 1/2] gitweb: allow access to forks with strict_export

On Sat, 2008-12-13 at 14:31 -0800, Junio C Hamano wrote:
Show 27 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > Matt McCutchen <matt@mattmccutchen.net> writes:
> >
> > CC-ed Petr Baudis, author of forks support in gitweb.
> >
> >> git_get_projects_list excludes forks in order to unclutter the main
> >> project list, but this caused the strict_export check, which also relies
> >> on git_get_project_list, to incorrectly fail for forks.  This patch adds
> >> an argument so git_get_projects_list knows when it is being called for a
> >> strict_export check (as opposed to a user-visible project list) and
> >> doesn't exclude the forks.
> >>
> >> Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
> >
> > Looks good for me.
> 
> That sounds like a broken API to me.
> 
> At least, please have the decency to not call the extra parameter "for
> strict export".  I would understand it if the extra parameter is called
> "toplevel_only" (or its negation, "include_forks").
> 
> IOW, don't name a parameter after the name of one caller that happens to
> want an unspecified special semantics, without saying what that special
> semantics is.  Instead, name it after the special semantics that the
> argument triggers.

I disagree. The parameter is really "include forks (if there is such a concept under the current config)", and with my second patch, it becomes "include hidden projects" too. That's really unwieldy.

In my view, the parameter makes the distinction between generating a filtered list for user consumption and a list of everything for a strict_export check. The particular semantics it activates may evolve as gitweb does (case in point: my second patch). The current semantics can be described in a comment on git_get_projects_list.

Granted, there may be a better name for the parameter than $for_strict_export. How about $include_all?

-- 
Matt

← back to recent threads