From: Jakub Narebski <jnareb@gmail.com>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCHv6 10/10] gitweb: group remote heads by remote
Date: Wed, 3 Nov 2010 01:58:52 +0200 [thread overview]
Message-ID: <201011030058.53366.jnareb@gmail.com> (raw)
In-Reply-To: <AANLkTinyi22OczYuD4urJKkfh8AzyuZoTzvzAvWa1Bo4@mail.gmail.com>
On Tue, 2 Nov 2010, Giuseppe Bilotta wrote:
> 2010/10/27 Jakub Narebski <jnareb@gmail.com>:
>> On Sun, 24 Oct 2010, Giuseppe Bilotta wrote:
>>
>>> In remote and summary view, display a block for each remote, with the
>>> fetch and push URL(s) as well as the list of the remote heads.
>>>
>>> In summary view, if the number of remotes is higher than a prescribed
>>> limit, only display the first <limit> remotes and their fetch and push
>>> urls, without any heads information and without grouping.
>> I guess that we can always implement more fancy limiting in the future
>> (e.g. taking into account total number of displayed remote heads).
>
> The limiting seems to be the most debatable part of this patch 8-)
I think that untill this feature gets into gitweb we can only guess
as to what kind of limiting would look and behave best on RL cases.
>>> +#
>>> +# It is possible to limit the retrieved remotes either by number
>>> +# (specifying a -limit parameter) or by name (-wanted parameter).
>>
>> I don't quite like limiting when generating, and would prefer do limiting
>> on display, especially if not doing limiting would not affect performance
>> much (git command invoked doesn't do limiting, like in case of
>> git_get_heads_list / git_get_tags_list or *most important* parse_commits).
>>
>> Especially if it complicates code that much (see below).
>>
>> Not doing limiting here, in git_get_remotes_list (or just git_get_remotes)
>> would also make API simpler; the single optional argument would be name of
>> remote we want to retrieve.
>
> Hm. By the same token, there would be no need to do the limiting even
> when trying to get information about a single remote, meaning we could
> make the sub totally parameter-less. OTOH, this would make the calling
> routine quite more complex (since it would have to check if the key is
> there, and then select that single key etc), much more so than
> limiting the number of displayed heads.
True, we have to balance complexity in generating function vs. complexity
in display code.
> I'll take the numerical limiting off the routine.
You meant here limiting number of remotes returned (except of case of
limiting to single remote), isn't it?
>>> +
>>> +# Takes a hash of remotes as first parameter and fills it by adding the
>>> +# available remote heads for each of the indicated remotes.
>>> +# A maximum number of heads can also be specified.
>>
>> All git_get_* subroutines _return_ something; this looks more like fill_*
>> function for me.
>
> I'm not particularly enamored with _get_, fill will do
We have fill_from_file_info, fill_project_list_info; I think
fill_remote_heads would be a good name.
>>
>>> +sub git_get_remote_heads {
>>> + my ($remotes, $limit) = @_;
>>> + my @heads = map { "remotes/$_" } keys %$remotes;
>>> + my @remoteheads = git_get_heads_list($limit, @heads);
>>> + foreach (keys %$remotes) {
>>> + my $remote = $_;
>>> + $remotes->{$remote}{'heads'} = [ grep {
>>> + $_->{'name'} =~ s!^$remote/!!
>>> + } @remoteheads ];
>>> + }
>>> +}
>>
>> We could remove limiting number of heads shown per remote also from here,
>> but this time 1.) the $limit parameter is passed down to git_get_heads_list
>> which in turn uses $limit as parameter to git command 2.) it doesn't
>> simplify code almost at all:
>>
>> +sub fill_remote_heads {
>> + my $remotes = shift;
>> +
>> + my @heads = map { "remotes/$_" } keys %$remotes;
>> + ## A QUESTION: perhaps it would be better to pass @remoteheads as parameter?
>> + my @remoteheads = git_get_heads_list(undef, @heads);
>> + foreach my $remote (keys %$remotes) {
>> + $remotes->{$remote}{'heads'} =
>> + [ grep { $_->{'name'} =~ s!^$remote/!! } @remoteheads ];
>> + }
>> +}
I now think that passing limit to fill_remote_heads (like you have) might
be a good solution (contrary to what I wrote earlier).
>> A QUESTION: perhaps it would be better to pass @remoteheads as parameter?
>> I wonder if won't end up with calling git_get_heads_list multiple times...
>> well, the improvement can be left for later. Answering this question
>> should not affect accepting this patch series.
>
> I'm not sure I actually understand the question. Who should we pass
> @remoteheads to?
I meant here passing @remoteheads or \@remoteheads, i.e. result of call
to git_get_heads_list, to fill_remote_heads (as one of parameters).
I was worrying, perhaps unnecessarily, about calling git_get_heads_list
more than once... but I guess that we did it anyway.
>>> +
>>> + my $urls = "<table class=\"projects_list\">\n" ;
>>> +
>>> + if (defined $fetch) {
>>> + if ($fetch eq $push) {
>>> + $urls .= format_repo_url("URL", $fetch);
>>> + } else {
>>> + $urls .= format_repo_url("Fetch URL", $fetch);
>>> + $urls .= format_repo_url("Push URL", $push) if defined $push;
>>> + }
>>> + } elsif (defined $push) {
>>> + $urls .= format_repo_url("Push URL", $push);
>>> + } else {
>>> + $urls .= format_repo_url("", "No remote URL");
>>> + }
>>> +
>>> + $urls .= "</table>\n";
>>
>> I'm not sure about naming this variable $urls...
>
> I'm open to suggestions. $urls_table ?
It is better.
>> Though I am not sure if it is good public API. Perhaps it is...
>
> The alternative would be to have git_remote to handle the single
> remote case, and possibly even have the action name be 'remote' rather
> than 'remotes' in that case.
We might want to have 'remote' as alias to 'remotes' anyway.
Though what you propose, having separately 'remotes' for list of all
remotes, and 'remote' + name of remote, might be a good idea.
Thank you on diligently working on this feature.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2010-11-02 23:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-24 10:45 [PATCHv6 00/10] gitweb: remote_heads feature Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 01/10] gitweb: introduce " Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 02/10] gitweb: git_get_heads_list accepts an optional list of refs Giuseppe Bilotta
2010-10-25 21:56 ` Jakub Narebski
2010-10-26 16:30 ` Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 03/10] gitweb: separate heads and remotes lists Giuseppe Bilotta
2010-10-25 15:01 ` Jakub Narebski
2010-10-25 18:14 ` Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 04/10] gitweb: nagivation menu for tags, heads and remotes Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 05/10] gitweb: use fullname as hash_base in heads link Giuseppe Bilotta
2010-10-25 14:56 ` Jakub Narebski
2010-10-25 15:07 ` Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 06/10] gitweb: allow action specialization in page header Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 07/10] gitweb: remotes view for a single remote Giuseppe Bilotta
2010-10-25 15:12 ` Jakub Narebski
2010-10-25 18:18 ` Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 08/10] gitweb: refactor repository URL printing Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 09/10] gitweb: provide a routine to display (sub)sections Giuseppe Bilotta
2010-10-25 15:15 ` Jakub Narebski
2010-10-25 18:21 ` Giuseppe Bilotta
2010-10-24 10:45 ` [PATCHv6 10/10] gitweb: group remote heads by remote Giuseppe Bilotta
2010-10-27 0:32 ` Jakub Narebski
2010-10-27 8:07 ` Jakub Narebski
2010-11-02 10:49 ` Giuseppe Bilotta
2010-11-02 23:58 ` Jakub Narebski [this message]
2010-11-03 7:49 ` Giuseppe Bilotta
2010-11-04 10:41 ` Jakub Narebski
2010-11-08 8:28 ` Giuseppe Bilotta
2010-11-08 11:05 ` Jakub Narebski
2010-11-08 11:18 ` Giuseppe Bilotta
2010-11-08 13:41 ` Jakub Narebski
2010-10-27 12:38 ` Jakub Narebski
2010-10-25 18:38 ` [PATCHv6 00/10] gitweb: remote_heads feature Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201011030058.53366.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=giuseppe.bilotta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).