git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: Add an option for adding more branch refs

From
Krzesimir Nowak <krzesimir@endocode.com>
Date
Nov 27, 2013, 16:15 UTC
Message-ID
<1385568927.2131.30.camel@localhost.localdomain>
In-Reply-To
<52961618.1070603@gmail.com>
On Wed, 2013-11-27 at 16:56 +0100, Jakub Narębski wrote:
Show 17 quoted lines
> Krzesimir Nowak wrote:
> 
> > Overriding an @additional_branch_refs configuration variable with
> > value ('wip') will make gitweb to show branches that appear in
> > refs/heads and refs/wip (refs/heads is hardcoded). Might be useful for
> > gerrit setups where user branches are not stored under refs/heads/.
> >
> 
> The description of this change starts with technical details,
> instead of starting with intent of this change.
> 
> Perhaps (this is only a proposal)
> 
>    Introduce @additional_branch_refs configuration variable, holding
>    names of references to be considered branches; by default empty.
>    For example setting it to ('wip') will make gitweb ...
> 

I have already posted second version of the patch. But I didn't change the commit message though. But thanks for proposal - it sounds better. I'll try to make it better next time I post a patch.

Show 7 quoted lines
> 
> BTW. I have thought at first that is something similar to 'remote_heads'
> feature, which among others adds 'remotes' section to 'summary' view
> displaying refs/remotes/* refs... but no, gitweb still doesn't treat 
> refs/remotes as branches, even with this feature set.
> 
> Nb. why new configuration variable, and not new %feature?

I dunno. Hard to tell where it fits. Junio told me about using "normal gitweb configuration mechanism", so that's the first thing that got my attention.

http://www.mail-archive.com/git@vger.kernel.org/msg39859.html
Show 48 quoted lines
> 
> > Signed-off-by: Krzesimir Nowak <krzesimir@endocode.com>
> > ---
> >  gitweb/gitweb.perl | 99 ++++++++++++++++++++++++++++++++++++++++--------------
> >  1 file changed, 74 insertions(+), 25 deletions(-)
> >
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 68c77f6..9bfd38b 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -17,6 +17,7 @@ use Encode;
> >  use Fcntl ':mode';
> >  use File::Find qw();
> >  use File::Basename qw(basename);
> > +use List::Util qw(min);
> >  use Time::HiRes qw(gettimeofday tv_interval);
> >  binmode STDOUT, ':utf8';
> >
> [...]
>  > @@ -3184,24 +3210,43 @@ sub git_get_project_owner {
>  >   	return $owner;
>  >   }
>  >
>  > -sub git_get_last_activity {
>  > -	my ($path) = @_;
>  > -	my $fd;
>  > +sub git_get_last_activity_age {
>  > +	my ($refs) = @_;
>  > +	my $fd = -1;
>  >
>  > -	$git_dir = "$projectroot/$path";
>  >   	open($fd, "-|", git_cmd(), 'for-each-ref',
>  >   	     '--format=%(committer)',
>  >   	     '--sort=-committerdate',
>  >   	     '--count=1',
>  > -	     'refs/heads') or return;
>  > +	     $refs) or return undef;
> 
> git-for-each-ref accepts more than one pattern. Why not simply
> 
>     	open($fd, "-|", git_cmd(), 'for-each-ref',
>     	     '--format=%(committer)',
>     	     '--sort=-committerdate',
>     	     '--count=1',
>    -	     'refs/heads') or return;
>    +	     get_branch_refs()) or return;
> 
> Then we won't need List::Util::min.

Yes, Junio pointed that out to me - fixed in second version of the patch.

Show 22 quoted lines
> 
> [...]
>  > +sub git_get_last_activity {
>  > +	my ($path) = @_;
>  > +	my @ages = ();
>  > +
>  > +	$git_dir = "$projectroot/$path";
>  > +	for my $ref (get_branch_refs()) {
>  > +		my $age = git_get_last_activity_age('refs/' . $_);
>  > +
>  > +		push @ages, $age if defined $age;
>  > +	}
>  > +	if (@ages) {
>  > +		my $min_age = min(@ages);
>  > +
>  > +		return ($min_age, age_string($min_age));
>  > +	}
>  > +
>  >   	return (undef, undef);
>  >   }
>  >
> [...]
-- 
Krzesimir Nowak
Software Developer
Endocode AG

krzesimir@endocode.com

------
Endocode AG, Johannisstraße 20, 10117 Berlin
info@endocode.com | www.endocode.com

Vorstandsvorsitzender: Mirko Boehm
Vorstände: Dr. Karl Beecher, Chris Kühl, Sebastian Sucker
Aufsichtsratsvorsitzende: Jennifer Beecher

Registergericht: Amtsgericht Charlottenburg - HRB 150748 B
Previous: Jakub Narębski
Message 5 of 5 in “gitweb: Add an option for adding more branch refs”
  1. gitweb: Add an option for adding more branch refsKrzesimir Nowak, Nov 26, 2013
  2. Junio C HamanoNov 26, 2013
  3. Krzesimir NowakNov 27, 2013
  4. Jakub NarębskiNov 27, 2013
  5. Krzesimir NowakNov 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.