git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitweb and remote branches
@ 2007-08-27 22:24 Giuseppe Bilotta
  2007-08-27 23:29 ` Jakub Narebski
       [not found] ` <cb7bb73a0708280253y7d31f347yb84a40982d59d9d2@mail.gmail.com>
  0 siblings, 2 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-27 22:24 UTC (permalink / raw)
  To: git

Hello all,

Currently, remote branch heads are only shown in the
shortlog, but I would like them to appear in the heads list,
together with the local branches. Is there some option for it?
I've browsed the gitweb source but I haven't found anything
that looked like it.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-27 22:24 gitweb and remote branches Giuseppe Bilotta
@ 2007-08-27 23:29 ` Jakub Narebski
       [not found] ` <cb7bb73a0708280253y7d31f347yb84a40982d59d9d2@mail.gmail.com>
  1 sibling, 0 replies; 25+ messages in thread
From: Jakub Narebski @ 2007-08-27 23:29 UTC (permalink / raw)
  To: git

[Cc: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>, git@vger.kernel.org]

Giuseppe Bilotta wrote:

> Currently, remote branch heads are only shown in the
> shortlog, but I would like them to appear in the heads list,
> together with the local branches. Is there some option for it?
> I've browsed the gitweb source but I haven't found anything
> that looked like it.

It is on my [long] TODO list for gitweb. But thanks for reminding
it.

Quick and dirty hack would be to change git for 'heads' view to accept
'-a' (all branches) extra option...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
       [not found]   ` <cb7bb73a0708280453k4315e80ej170238a52e66dcb6@mail.gmail.com>
@ 2007-08-29 22:01     ` Jakub Narebski
  2007-08-30  7:18       ` Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Jakub Narebski @ 2007-08-29 22:01 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git

On Tue, 28 August 2007, Giuseppe Bilotta wrote:
> On 8/28/07, Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
>>
>> I've given a better look at the code and I think I can whip up a patch
>> to implement the feature. I have no idea about how to create a new
>> option in gitweb though, so I'll have to leave it that to someone
>> else.
> 
> Ok, this is hopefully the last time I reply to myself. I'm inlining
> the quick'n'dirty patch I've whipped up, hoping that gmail doesn't
> destroy it too much..

For quick'n'dirty solution this might be enough. For proper patch to
be accepted I don't think so.

First, in the idea to show also remote branches (from refs/remotes),
I wanted to separate heads list from remotes list in the 'summary'
view, and add 'remotes' view or modify 'heads' view to accept some
parameter specyfying kind of refs.

Second, what was stopping me from implementing that was an idea to
separate remote branches into categories (like gitwbe-xmms2 categories
of projects) defined by the remote it belongs to. And this is not so
easy if we want to respect old .git/branches/ and .git/remotes/ remote
config in addition to new config based remote config.

> -- 
> Giuseppe "Oblomov" Bilotta
> 
> --- gitweb.cgi	2007-08-26 12:41:13.000000000 +0200
> +++ gitweb.cgi-my	2007-08-28 13:47:15.000000000 +0200

It is better to use git to manage source and to generate patches
(use git-format-patch, check Documentation/SubmittingPatches),
and use gitweb/gitweb.perl and not installed version.

[...]
> @@ -1677,8 +1677,9 @@ sub git_get_heads_list {
>  		my ($hash, $name, $title) = split(' ', $refinfo, 3);
>  		my ($committer, $epoch, $tz) =
>  			($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
> -		$name =~ s!^refs/heads/!!;
> +		$name =~ s!^refs/(head|remote)s/!!;
> 
> +		$ref_item{'class'}  = $1;
>  		$ref_item{'name'}  = $name;
>  		$ref_item{'id'}    = $hash;
>  		$ref_item{'title'} = $title || '(no commit message)';

Nice, although very minor nit: I'd use

> +		$ref_item{'class'} = $1;


> @@ -3237,8 +3238,10 @@ sub git_heads_body {
>  		$alternate ^= 1;
>  		print "<td><i>$ref{'age'}</i></td>\n" .
>  		      ($curr ? "<td class=\"current_head\">" : "<td>") .
> +		      "<span class=\"refs\"><span class=\"$ref{'class'}\">" .
>  		      $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'}),
>  		               -class => "list name"},esc_html($ref{'name'})) .
> +		      "</span></span>" .
>  		      "</td>\n" .
>  		      "<td class=\"link\">" .
>  		      $cgi->a({-href => href(action=>"shortlog",
> hash=>$ref{'name'})}, "shortlog") . " | " .
> 

I don't understand this double span. First, you can set multiple
classes for HTML element by separating them by space, e.g.

		"<span class=\"refs\ $ref{'class'}\">"

And you could have given appropriate class to <td> or <a> element

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-29 22:01     ` Jakub Narebski
@ 2007-08-30  7:18       ` Giuseppe Bilotta
  2007-08-30  8:16         ` Jakub Narebski
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-30  7:18 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On 8/30/07, Jakub Narebski <jnareb@gmail.com> wrote:
> For quick'n'dirty solution this might be enough. For proper patch to
> be accepted I don't think so.

That's fine, it wasn't meant to be :)

> First, in the idea to show also remote branches (from refs/remotes),
> I wanted to separate heads list from remotes list in the 'summary'
> view, and add 'remotes' view or modify 'heads' view to accept some
> parameter specyfying kind of refs.

What I had in mind was a way to modify 'heads' view with a boolean
option that enable/disabled remotes view. For their visualizations, I
had in mind a split 'heads' secion, with the lhs being as it is now,
and the rhs having the remotes.

However, I wasn't sure if such a view would have been appreciated, so
I went for the merged view and used the spans to make the heads appear
as they do in the shortlog, as a clear way to mark which ones were
local and which ones were remote.

> Second, what was stopping me from implementing that was an idea to
> separate remote branches into categories (like gitwbe-xmms2 categories
> of projects) defined by the remote it belongs to. And this is not so
> easy if we want to respect old .git/branches/ and .git/remotes/ remote
> config in addition to new config based remote config.

I don't know what gitweb-xmms2 does, but I think I understand what you
mean, and I like the idea. However, it's even harder if you consider
that even the latest git-svn plops all the svn-converted refs straight
into refs/remotes and not in a subdir such as refs/remotes/svn.

OTOH, we have to start from somewhere so we can build the feature step by step.

> > Giuseppe "Oblomov" Bilotta
> >
> > --- gitweb.cgi        2007-08-26 12:41:13.000000000 +0200
> > +++ gitweb.cgi-my     2007-08-28 13:47:15.000000000 +0200
>
> It is better to use git to manage source and to generate patches
> (use git-format-patch, check Documentation/SubmittingPatches),
> and use gitweb/gitweb.perl and not installed version.

Oh, I know, this was just a very quick hack on the thing installed by
my Debian distribution. I've since checkoued out the git.git
repository and I'll be working on that now.

> > @@ -3237,8 +3238,10 @@ sub git_heads_body {
> >               $alternate ^= 1;
> >               print "<td><i>$ref{'age'}</i></td>\n" .
> >                     ($curr ? "<td class=\"current_head\">" : "<td>") .
> > +                   "<span class=\"refs\"><span class=\"$ref{'class'}\">" .
> >                     $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'}),
> >                              -class => "list name"},esc_html($ref{'name'})) .
> > +                   "</span></span>" .
> >                     "</td>\n" .
> >                     "<td class=\"link\">" .
> >                     $cgi->a({-href => href(action=>"shortlog",
> > hash=>$ref{'name'})}, "shortlog") . " | " .
> >
>
> I don't understand this double span. First, you can set multiple
> classes for HTML element by separating them by space, e.g.
>
>                 "<span class=\"refs\ $ref{'class'}\">"
>
> And you could have given appropriate class to <td> or <a> element

Actually, that was just a quick hack to make the heads appear in the
heads list in the same way as they appear in the shortlog, to
differentiate between them. And that requires the double span ;)

Of course, I'd rather hack the CSS now that I've got the git repository.

I'll be working on it here

http://oblomov.dnsalias.org/git?p=git.git;a=shortlog;h=gitweb-allheads

and keep you posted on my progress.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30  7:18       ` Giuseppe Bilotta
@ 2007-08-30  8:16         ` Jakub Narebski
  2007-08-30  9:09           ` Giuseppe Bilotta
  2007-08-30 21:07           ` Junio C Hamano
  0 siblings, 2 replies; 25+ messages in thread
From: Jakub Narebski @ 2007-08-30  8:16 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: git

On Thu, 30 August 2007, Giuseppe Bilotta wrote:
> On 8/30/07, Jakub Narebski <jnareb@gmail.com> wrote:

>> First, in the idea to show also remote branches (from refs/remotes),
>> I wanted to separate heads list from remotes list in the 'summary'
>> view, and add 'remotes' view or modify 'heads' view to accept some
>> parameter specyfying kind of refs.
> 
> What I had in mind was a way to modify 'heads' view with a boolean
> option that enable/disabled remotes view.

That is a good idea. We can for example use extra_options ('opt')
parameter to pass 'refs/remotes' etc. to 'heads' view. Or we can
use some new CGI parameter. Or just make it configurable in gitweb
configuration, with per repository override, i.e. make it into
%feature.

> For their visualizations, I 
> had in mind a split 'heads' secion, with the lhs being as it is now,
> and the rhs having the remotes.

Care to provide some ascii-art mockup?

What I had in mind was for 'summary' view (*bold*, _underline_):

  [heads]
  27 min ago       _gitweb-allheads_   shortlog | log | tree
  24 hours ago     master 	       shortlog | log | tree

  [remotes]
  *origin*
    24 hours ago    man        shortlog | log | tree
    24 hours ago    html       shortlog | log | tree
    24 hours ago    next       shortlog | log | tree
    24 hours ago    pu         shortlog | log | tree
    24 hours ago    _master_   shortlog | log | tree
    2 weeks ago     maint      shortlog | log | tree
    2 weeks ago     todo       shortlog | log | tree

and similarly for 'remotes' view (or 'heads').

Note that we remove remote name from remote branch name, although
we can leave it as is (i.e. origin/man vs. man), and that we filter
out HEAD if it points to existing branch, marking one of the branches
as current instead.

That reminds me that gitweb has no support for detached HEAD as of yet,
although I don't think we want to encourage detached HEAD in public 
repo.

> However, I wasn't sure if such a view would have been appreciated, so
> I went for the merged view and used the spans to make the heads appear
> as they do in the shortlog, as a clear way to mark which ones were
> local and which ones were remote.

On

  http://oblomov.dnsalias.org/git?p=git.git;a=heads

I don't see any difference between formatting of remote heads and local
branches.
 
>> Second, what was stopping me from implementing that was an idea to
>> separate remote branches into categories (like gitwbe-xmms2
>> categories of projects) defined by the remote it belongs to. And
>> this is not so easy if we want to respect old .git/branches/
>> and .git/remotes/ remote config in addition to new config based
>> remote config. 
> 
> I don't know what gitweb-xmms2 does, but I think I understand what you
> mean, and I like the idea.

See my mockup and 'summary' view of gitweb-xmms2 installation:
  http://git.xmms.se/

> However, it's even harder if you consider 
> that even the latest git-svn plops all the svn-converted refs straight
> into refs/remotes and not in a subdir such as refs/remotes/svn.

Or refs/svn. I think that dumping remotes directly into refs/remotes
and not to refs/remotes/<remote> is a bug (also in git-svn).

> OTOH, we have to start from somewhere so we can build the feature
> step by step. 

We can start without separating into remotes category-like, i.e.
with the following mockup:

  [remotes]
    24 hours ago    origin/man        shortlog | log | tree
    24 hours ago    origin/html       shortlog | log | tree
    24 hours ago    origin/next       shortlog | log | tree
    24 hours ago    origin/pu         shortlog | log | tree
    24 hours ago    _origin/master_   shortlog | log | tree
    2 weeks ago     origin/maint      shortlog | log | tree
    2 weeks ago     origin/todo       shortlog | log | tree

 
[...]

> I'll be working on it here
> 
> http://oblomov.dnsalias.org/git?p=git.git;a=shortlog;h=gitweb-allheads
> 
> and keep you posted on my progress.

You can also make a git fork at http://repo.or.cz

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30  8:16         ` Jakub Narebski
@ 2007-08-30  9:09           ` Giuseppe Bilotta
  2007-08-30 21:07           ` Junio C Hamano
  1 sibling, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-30  9:09 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

On 8/30/07, Jakub Narebski <jnareb@gmail.com> wrote:
> On Thu, 30 August 2007, Giuseppe Bilotta wrote:
> > What I had in mind was a way to modify 'heads' view with a boolean
> > option that enable/disabled remotes view.
>
> That is a good idea. We can for example use extra_options ('opt')
> parameter to pass 'refs/remotes' etc. to 'heads' view. Or we can
> use some new CGI parameter. Or just make it configurable in gitweb
> configuration, with per repository override, i.e. make it into
> %feature.

For the time being I've made it into a project-overridable %feature.
(It was easier to set up than I though.) I do like the idea of having
it also as an additional CGI parameter.

> > For their visualizations, I
> > had in mind a split 'heads' secion, with the lhs being as it is now,
> > and the rhs having the remotes.
>
> Care to provide some ascii-art mockup?

(monospace view)

[heads]                | [remotes]
date headname links    | date headname links
date headname links    | date headname links

or a variation thereof. However, I have a 1600x1200 screen so not
everybody might be confortable with such a view.

> What I had in mind was for 'summary' view (*bold*, _underline_):
>
>   [heads]
>   27 min ago       _gitweb-allheads_   shortlog | log | tree
>   24 hours ago     master              shortlog | log | tree
>
>   [remotes]
>   *origin*
>     24 hours ago    man        shortlog | log | tree
>     24 hours ago    html       shortlog | log | tree
>     24 hours ago    next       shortlog | log | tree
>     24 hours ago    pu         shortlog | log | tree
>     24 hours ago    _master_   shortlog | log | tree
>     2 weeks ago     maint      shortlog | log | tree
>     2 weeks ago     todo       shortlog | log | tree
>
> and similarly for 'remotes' view (or 'heads').

I think I like yours better. I had just implemented split
remotes/heads list in summary view, so I'll keep working towards your
idea.

> Note that we remove remote name from remote branch name, although
> we can leave it as is (i.e. origin/man vs. man),

Yes, I'll work on this next.

> and that we filter
> out HEAD if it points to existing branch, marking one of the branches
> as current instead.

I don't know if I'll be able to implement this, but I'll try :)

> > However, I wasn't sure if such a view would have been appreciated, so
> > I went for the merged view and used the spans to make the heads appear
> > as they do in the shortlog, as a clear way to mark which ones were
> > local and which ones were remote.
>
> On
>
>   http://oblomov.dnsalias.org/git?p=git.git;a=heads
>
> I don't see any difference between formatting of remote heads and local
> branches.

Indeed, I removed the thing when I started working on the repo.

> > However, it's even harder if you consider
> > that even the latest git-svn plops all the svn-converted refs straight
> > into refs/remotes and not in a subdir such as refs/remotes/svn.
>
> Or refs/svn. I think that dumping remotes directly into refs/remotes
> and not to refs/remotes/<remote> is a bug (also in git-svn).

I think so too. I'll report it as a bug to the git-svn developers.

> > I'll be working on it here
> >
> > http://oblomov.dnsalias.org/git?p=git.git;a=shortlog;h=gitweb-allheads
> >
> > and keep you posted on my progress.
>
> You can also make a git fork at http://repo.or.cz

Oh, interesting. Just clicking on the 'fork' link in
http://repo.or.cz/w/git/gitweb.git and filling up the form?

I'll set that up as a mirror shortly.


-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30  8:16         ` Jakub Narebski
  2007-08-30  9:09           ` Giuseppe Bilotta
@ 2007-08-30 21:07           ` Junio C Hamano
  2007-08-30 23:09             ` Giuseppe Bilotta
  1 sibling, 1 reply; 25+ messages in thread
From: Junio C Hamano @ 2007-08-30 21:07 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Giuseppe Bilotta, git

Jakub Narebski <jnareb@gmail.com> writes:

> That reminds me that gitweb has no support for detached HEAD as of yet,
> although I don't think we want to encourage detached HEAD in public 
> repo.

That logic is flawed, I am afraid.  If you have been talking
only about serving public repository via gitweb, then the topic
of the thread becomes totally moot.  Exposing or even having
remotes/ in public distribution point repository would be even
more wrong than using detached HEAD in public repository.  Other
people who interact with you should not have any business what
you happened to have fetched from _your_ upstream --- if you
want to publish them and act as a relay for your downstream,
then they should be fetched from your branch namespace.

But obviously people use gitweb/instaweb as a way to view their
own live repository, and I think it makes sense to show and
support remotes/ in such a case.  It also would make sense to
support detached HEAD there as well.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30 21:07           ` Junio C Hamano
@ 2007-08-30 23:09             ` Giuseppe Bilotta
  2007-08-30 23:53               ` Jakub Narebski
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-30 23:09 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jakub Narebski, git

On 8/30/07, Junio C Hamano <gitster@pobox.com> wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
> > That reminds me that gitweb has no support for detached HEAD as of yet,
> > although I don't think we want to encourage detached HEAD in public
> > repo.
>
> That logic is flawed, I am afraid.  If you have been talking
> only about serving public repository via gitweb, then the topic
> of the thread becomes totally moot.  Exposing or even having
> remotes/ in public distribution point repository would be even
> more wrong than using detached HEAD in public repository.  Other
> people who interact with you should not have any business what
> you happened to have fetched from _your_ upstream --- if you
> want to publish them and act as a relay for your downstream,
> then they should be fetched from your branch namespace.

OTOH, having 'origin' exposed, and knowing the 'origin' URL, would
open lots of interesting fields of research, such as distributed git
mirroring to download large repositories from more than a client etc.

Anyway, making visible remotes an option that defaults to disabled
would address both the issue above and the one below:

> But obviously people use gitweb/instaweb as a way to view their
> own live repository, and I think it makes sense to show and
> support remotes/ in such a case.  It also would make sense to
> support detached HEAD there as well.

If I understand correctly, a detached HEAD is simply a checkout in the
middle of a branch, and thus not named. So what exactly are we looking
for when we talk about supporting a detached HEAD? Would it be enough
to display HEAD in the list of heads?

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30 23:09             ` Giuseppe Bilotta
@ 2007-08-30 23:53               ` Jakub Narebski
  2007-08-30 23:59                 ` Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Jakub Narebski @ 2007-08-30 23:53 UTC (permalink / raw)
  To: Giuseppe Bilotta; +Cc: Junio C Hamano, git

On Fri, 31 August 2007, Giuseppe Bilotta wrote:
> On 8/30/07, Junio C Hamano <gitster@pobox.com> wrote:
>> Jakub Narebski <jnareb@gmail.com> writes:
>>
>>> That reminds me that gitweb has no support for detached HEAD as of yet,
>>> although I don't think we want to encourage detached HEAD in public
>>> repo.
[...]
>> But obviously people use gitweb/instaweb as a way to view their
>> own live repository, and I think it makes sense to show and
>> support remotes/ in such a case.  It also would make sense to
>> support detached HEAD there as well.
> 
> If I understand correctly, a detached HEAD is simply a checkout in the
> middle of a branch, and thus not named. So what exactly are we looking
> for when we talk about supporting a detached HEAD? Would it be enough
> to display HEAD in the list of heads?

I think we want display HEAD in the list of heads if it is detached,
and also use it as a ref marker, while only marking (with undeline or
bold style) current head as such if HEAD is not detached, i.e. is
symref or symlink.

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30 23:53               ` Jakub Narebski
@ 2007-08-30 23:59                 ` Giuseppe Bilotta
  2007-08-31  2:15                   ` Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-30 23:59 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Junio C Hamano, git

On 8/31/07, Jakub Narebski <jnareb@gmail.com> wrote:
> On Fri, 31 August 2007, Giuseppe Bilotta wrote:
> > If I understand correctly, a detached HEAD is simply a checkout in the
> > middle of a branch, and thus not named. So what exactly are we looking
> > for when we talk about supporting a detached HEAD? Would it be enough
> > to display HEAD in the list of heads?
>
> I think we want display HEAD in the list of heads if it is detached,
> and also use it as a ref marker, while only marking (with undeline or
> bold style) current head as such if HEAD is not detached, i.e. is
> symref or symlink.

I thought so.

Of course, I've just discovered that for-each-ref ignores HEAD, so I
have to do it the hard route ...

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: gitweb and remote branches
  2007-08-30 23:59                 ` Giuseppe Bilotta
@ 2007-08-31  2:15                   ` Giuseppe Bilotta
  2007-08-31 10:54                     ` [PATCH 01/14] gitweb: get remotes too when getting heads list Giuseppe Bilotta
                                       ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31  2:15 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: Junio C Hamano, git

On 8/31/07, Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
> On 8/31/07, Jakub Narebski <jnareb@gmail.com> wrote:
> > On Fri, 31 August 2007, Giuseppe Bilotta wrote:
> > > If I understand correctly, a detached HEAD is simply a checkout in the
> > > middle of a branch, and thus not named. So what exactly are we looking
> > > for when we talk about supporting a detached HEAD? Would it be enough
> > > to display HEAD in the list of heads?
> >
> > I think we want display HEAD in the list of heads if it is detached,
> > and also use it as a ref marker, while only marking (with undeline or
> > bold style) current head as such if HEAD is not detached, i.e. is
> > symref or symlink.

Ok, implementation at

http://oblomov.dnsalias.org/git?p=git.git;a=summary

comments welcome. You can see it in action here

http://oblomov.dnsalias.org/git?p=gittest.git;a=summary

It may not be the smartest implementation, but it's what I could cook
up with my limited git knowledge. Plus, since it's WAY past my
bedtime, I'll have to dealy publishing my gitweb-allheads at least
until tomorrow.

Have fun,

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 01/14] gitweb: get remotes too when getting heads list
  2007-08-31  2:15                   ` Giuseppe Bilotta
@ 2007-08-31 10:54                     ` Giuseppe Bilotta
  2007-08-31 10:55                     ` [PATCH 02/14] gitweb: make remote heads in heads list optional Giuseppe Bilotta
                                       ` (6 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 10:54 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b2bae1b..65953db 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2063,7 +2063,7 @@ sub git_get_heads_list {
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads'
+		'refs/heads', 'refs/remotes'
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
@@ -2073,8 +2073,9 @@ sub git_get_heads_list {
 		my ($hash, $name, $title) = split(' ', $refinfo, 3);
 		my ($committer, $epoch, $tz) =
 			($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
-		$name =~ s!^refs/heads/!!;
+		$name =~ s!^refs/(head|remote)s/!!;
 
+		$ref_item{'class'} = $1;
 		$ref_item{'name'}  = $name;
 		$ref_item{'id'}    = $hash;
 		$ref_item{'title'} = $title || '(no commit message)';
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 02/14] gitweb: make remote heads in heads list optional
  2007-08-31  2:15                   ` Giuseppe Bilotta
  2007-08-31 10:54                     ` [PATCH 01/14] gitweb: get remotes too when getting heads list Giuseppe Bilotta
@ 2007-08-31 10:55                     ` Giuseppe Bilotta
  2007-08-31 10:55                     ` [PATCH 03/14] gitweb: git_get_heads_list now accepts an optional list of refs Giuseppe Bilotta
                                       ` (5 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 65953db..6514bef 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -271,6 +271,18 @@ our %feature = (
 	'forks' => {
 		'override' => 0,
 		'default' => [0]},
+
+	# Make gitweb show remotes too in the heads list
+
+	# To enable system wide have in $GITWEB_CONFIG
+	# $feature{'remote_heads'}{'default'} = [1];
+	# To have project specific config enable override in $GITWEB_CONFIG
+	# $feature{'remote_heads'}{'override'} = 1;
+	# and in project config gitweb.remote_heads = 0|1;
+	'remote_heads' => {
+		'sub' => \&feature_remote_heads,
+		'override' => 0,
+		'default' => [0]},
 );
 
 sub gitweb_check_feature {
@@ -336,6 +348,18 @@ sub feature_pickaxe {
 	return ($_[0]);
 }
 
+sub feature_remote_heads {
+	my ($val) = git_get_project_config('remote_heads', '--bool');
+
+	if ($val eq 'true') {
+		return (1);
+	} elsif ($val eq 'false') {
+		return (0);
+	}
+
+	return ($_[0]);
+}
+
 # checking HEAD file with -e is fragile if the repository was
 # initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
 # and then pruned.
@@ -2060,10 +2084,12 @@ sub git_get_heads_list {
 	my $limit = shift;
 	my @headslist;
 
+	my ($remote_heads) = gitweb_check_feature('remote_heads');
+
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads', 'refs/remotes'
+		'refs/heads', ( $remote_heads ? 'refs/remotes' : '')
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 03/14] gitweb: git_get_heads_list now accepts an optional list of refs.
  2007-08-31  2:15                   ` Giuseppe Bilotta
  2007-08-31 10:54                     ` [PATCH 01/14] gitweb: get remotes too when getting heads list Giuseppe Bilotta
  2007-08-31 10:55                     ` [PATCH 02/14] gitweb: make remote heads in heads list optional Giuseppe Bilotta
@ 2007-08-31 10:55                     ` Giuseppe Bilotta
  2007-08-31 10:55                     ` [PATCH 04/14] gitweb: separate heads and remotes list in summary view Giuseppe Bilotta
                                       ` (4 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

git_get_heads_list(limit, dir1, dir2, ...) can now be used to retrieve refs/dir1, refs/dir2 etc.
Defaults to ('heads') or ('heads', 'remotes') depending on the remote_heads option.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6514bef..4b27352 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2081,15 +2081,18 @@ sub parse_from_to_diffinfo {
 ## parse to array of hashes functions
 
 sub git_get_heads_list {
-	my $limit = shift;
+	my ($limit, @class) = @_;
+	unless (defined @class) {
+		my ($remote_heads) = gitweb_check_feature('remote_heads');
+		@class = ('heads', $remote_heads ? 'remotes' : undef);
+	}
+	my @refs = map { "refs/$_" } @class ;
 	my @headslist;
 
-	my ($remote_heads) = gitweb_check_feature('remote_heads');
-
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-		'refs/heads', ( $remote_heads ? 'refs/remotes' : '')
+		@refs
 		or return;
 	while (my $line = <$fd>) {
 		my %ref_item;
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 04/14] gitweb: separate heads and remotes list in summary view
  2007-08-31  2:15                   ` Giuseppe Bilotta
                                       ` (2 preceding siblings ...)
  2007-08-31 10:55                     ` [PATCH 03/14] gitweb: git_get_heads_list now accepts an optional list of refs Giuseppe Bilotta
@ 2007-08-31 10:55                     ` Giuseppe Bilotta
  2007-08-31 10:59                     ` [PATCH 05/14] gitweb: allow refs passed to git_heads_body to use a name different from the hash name Giuseppe Bilotta
                                       ` (3 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 10:55 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4b27352..6aec28e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3804,6 +3804,7 @@ sub git_summary {
 	my %co = parse_commit("HEAD");
 	my %cd = %co ? parse_date($co{'committer_epoch'}, $co{'committer_tz'}) : ();
 	my $head = $co{'id'};
+	my ($remote_heads) = gitweb_check_feature('remote_heads');
 
 	my $owner = git_get_project_owner($project);
 
@@ -3811,7 +3812,8 @@ sub git_summary {
 	# These get_*_list functions return one more to allow us to see if
 	# there are more ...
 	my @taglist  = git_get_tags_list(16);
-	my @headlist = git_get_heads_list(16);
+	my @headlist = git_get_heads_list(16, 'heads');
+	my @remotelist = $remote_heads ? git_get_heads_list(16, 'remotes') : ();
 	my @forklist;
 	my ($check_forks) = gitweb_check_feature('forks');
 
@@ -3874,6 +3876,13 @@ sub git_summary {
 		               $cgi->a({-href => href(action=>"heads")}, "..."));
 	}
 
+	if (@remotelist) {
+		git_print_header_div('remotes');
+		git_heads_body(\@remotelist, $head, 0, 15,
+		               $#remotelist <= 15 ? undef :
+		               $cgi->a({-href => href(action=>"heads")}, "..."));
+	}
+
 	if (@forklist) {
 		git_print_header_div('forks');
 		git_project_list_body(\@forklist, undef, 0, 15,
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 05/14] gitweb: allow refs passed to git_heads_body to use a name different from the hash name
  2007-08-31  2:15                   ` Giuseppe Bilotta
                                       ` (3 preceding siblings ...)
  2007-08-31 10:55                     ` [PATCH 04/14] gitweb: separate heads and remotes list in summary view Giuseppe Bilotta
@ 2007-08-31 10:59                     ` Giuseppe Bilotta
  2007-08-31 11:05                     ` [PATCH 06/14] gitweb: git_split_heads_body function Giuseppe Bilotta
                                       ` (2 subsequent siblings)
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 10:59 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6aec28e..c46e982 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3657,16 +3657,18 @@ sub git_heads_body {
 		} else {
 			print "<tr class=\"light\">\n";
 		}
+		my $hname = $ref{'hname'} || $ref{'name'};
+		my $name = $ref{'name'};
 		$alternate ^= 1;
 		print "<td><i>$ref{'age'}</i></td>\n" .
 		      ($curr ? "<td class=\"current_head\">" : "<td>") .
-		      $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'}),
-		               -class => "list name"},esc_html($ref{'name'})) .
+		      $cgi->a({-href => href(action=>"shortlog", hash=>$hname),
+		               -class => "list name"},esc_html($name)) .
 		      "</td>\n" .
 		      "<td class=\"link\">" .
-		      $cgi->a({-href => href(action=>"shortlog", hash=>$ref{'name'})}, "shortlog") . " | " .
-		      $cgi->a({-href => href(action=>"log", hash=>$ref{'name'})}, "log") . " | " .
-		      $cgi->a({-href => href(action=>"tree", hash=>$ref{'name'}, hash_base=>$ref{'name'})}, "tree") .
+		      $cgi->a({-href => href(action=>"shortlog", hash=>$hname)}, "shortlog") . " | " .
+		      $cgi->a({-href => href(action=>"log", hash=>$hname)}, "log") . " | " .
+		      $cgi->a({-href => href(action=>"tree", hash=>$hname, hash_base=>$hname)}, "tree") .
 		      "</td>\n" .
 		      "</tr>";
 	}
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 06/14] gitweb: git_split_heads_body function.
  2007-08-31  2:15                   ` Giuseppe Bilotta
                                       ` (4 preceding siblings ...)
  2007-08-31 10:59                     ` [PATCH 05/14] gitweb: allow refs passed to git_heads_body to use a name different from the hash name Giuseppe Bilotta
@ 2007-08-31 11:05                     ` Giuseppe Bilotta
  2007-08-31 11:18                     ` [PATCH 07/14] gitweb: use CSS to style split head lists Giuseppe Bilotta
  2007-08-31 11:19                     ` [PATCH 10/14] gitweb: display HEAD in heads list when detached Giuseppe Bilotta
  7 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:05 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

The purpose of this function is to split a headlist into groups determined by the leading part of the refname, and call git_heads_body() on each group.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c46e982..cacb0d7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3640,6 +3640,37 @@ sub git_tags_body {
 	print "</table>\n";
 }
 
+sub git_split_heads_body {
+	my ($headlist, $head, $from, $to, $extra) = @_;
+	my %headlists;
+	my $leader; my $list; my @list;
+
+	# Split @$headlist into a hash of lists
+	map {
+		my %ref = %$_;
+		$ref{'hname'} = $ref{'name'};
+		if ($ref{'name'} =~ /\//) {
+			$ref{'name'} =~ s!^([^/]+)/!!;
+			$leader = $1;
+		} else {
+			$leader = "\000";
+		}
+		if (defined $headlists{$leader}) {
+			@list = @{$headlists{$leader}}
+		} else {
+			@list = ()
+		}
+		push @list, \%ref;
+		$headlists{$leader} = [@list];
+	} @$headlist;
+
+	foreach $leader (sort(keys %headlists)) {
+		print "<b>$leader</b><br/>\n" unless $leader eq "\000";
+		$list = $headlists{$leader};
+		git_heads_body($list, $head, $from, $to, $extra);
+	}
+}
+
 sub git_heads_body {
 	# uses global variable $project
 	my ($headlist, $head, $from, $to, $extra) = @_;
@@ -3880,7 +3911,7 @@ sub git_summary {
 
 	if (@remotelist) {
 		git_print_header_div('remotes');
-		git_heads_body(\@remotelist, $head, 0, 15,
+		git_split_heads_body(\@remotelist, $head, 0, 15,
 		               $#remotelist <= 15 ? undef :
 		               $cgi->a({-href => href(action=>"heads")}, "..."));
 	}
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 07/14] gitweb: use CSS to style split head lists.
  2007-08-31  2:15                   ` Giuseppe Bilotta
                                       ` (5 preceding siblings ...)
  2007-08-31 11:05                     ` [PATCH 06/14] gitweb: git_split_heads_body function Giuseppe Bilotta
@ 2007-08-31 11:18                     ` Giuseppe Bilotta
  2007-08-31 11:18                       ` [PATCH 08/14] gitweb: add 'remotes' action as a synonym for git_heads() Giuseppe Bilotta
  2007-08-31 11:19                     ` [PATCH 10/14] gitweb: display HEAD in heads list when detached Giuseppe Bilotta
  7 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Introduce a new div class 'subsection' in the CSS and use it to style split head lists.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.css  |   10 ++++++++++
 gitweb/gitweb.perl |    4 +++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 1b88879..c36b20a 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -8,6 +8,16 @@ body {
 	color: #000000;
 }
 
+div.subsection {
+	border: solid #d9d8d1;
+	border-width: 1px;
+	margin: 10px;
+}
+
+.subsection .title {
+	font-size: smaller;
+}
+
 a {
 	color: #0000cc;
 }
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index cacb0d7..dc9727e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3665,9 +3665,11 @@ sub git_split_heads_body {
 	} @$headlist;
 
 	foreach $leader (sort(keys %headlists)) {
-		print "<b>$leader</b><br/>\n" unless $leader eq "\000";
+		print "<div class=\"subsection\">\n";
+		git_print_header_div(undef, $leader) unless $leader eq "\000";
 		$list = $headlists{$leader};
 		git_heads_body($list, $head, $from, $to, $extra);
+		print "</div>\n";
 	}
 }
 
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 08/14] gitweb: add 'remotes' action as a synonym for git_heads()
  2007-08-31 11:18                     ` [PATCH 07/14] gitweb: use CSS to style split head lists Giuseppe Bilotta
@ 2007-08-31 11:18                       ` Giuseppe Bilotta
  2007-08-31 11:18                         ` [PATCH 09/14] gitweb: split heads list in head view if appropriate Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dc9727e..6dfb2f4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -562,6 +562,7 @@ my %actions = (
 	"commit" => \&git_commit,
 	"forks" => \&git_forks,
 	"heads" => \&git_heads,
+	"remotes" => \&git_heads,
 	"history" => \&git_history,
 	"log" => \&git_log,
 	"rss" => \&git_rss,
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 09/14] gitweb: split heads list in head view if appropriate
  2007-08-31 11:18                       ` [PATCH 08/14] gitweb: add 'remotes' action as a synonym for git_heads() Giuseppe Bilotta
@ 2007-08-31 11:18                         ` Giuseppe Bilotta
  0 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:18 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6dfb2f4..09d9793 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4195,6 +4195,9 @@ sub git_heads {
 
 	my @headslist = git_get_heads_list();
 	if (@headslist) {
+		my ($remote_heads) = gitweb_check_feature('remote_heads');
+		$remote_heads ? 
+		git_split_heads_body(\@headslist, $head) :
 		git_heads_body(\@headslist, $head);
 	}
 	git_footer_html();
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 10/14] gitweb: display HEAD in heads list when detached
  2007-08-31  2:15                   ` Giuseppe Bilotta
                                       ` (6 preceding siblings ...)
  2007-08-31 11:18                     ` [PATCH 07/14] gitweb: use CSS to style split head lists Giuseppe Bilotta
@ 2007-08-31 11:19                     ` Giuseppe Bilotta
  2007-08-31 11:19                       ` [PATCH 11/14] gitweb: git_is_head_detached() function Giuseppe Bilotta
  7 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 09d9793..e743c3d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2090,6 +2090,27 @@ sub git_get_heads_list {
 	my @refs = map { "refs/$_" } @class ;
 	my @headslist;
 
+	if (grep { $_ eq 'heads' } @class) {
+		my @x = (git_cmd(), 'branch');
+		my @ret = split("\n", qx(@x));
+		if (grep { /^* \(no branch\)$/ } @ret) { ;
+			my %ref_item;
+			@x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
+			my ($hash, $epoch, $title) = split("\n", qx(@x), 3);
+
+			$ref_item{'class'} = 'head';
+			$ref_item{'name'} = 'HEAD';
+			$ref_item{'id'} = $hash;
+			$ref_item{'title'} = $title || '(no commit message)';
+			if ($ref_item{'epoch'} = $epoch) {
+				$ref_item{'age'} = age_string(time - $ref_item{'epoch'});
+			} else {
+				$ref_item{'age'} = "unknown";
+			}
+			push @headslist, \%ref_item;
+		}
+	}
+
 	open my $fd, '-|', git_cmd(), 'for-each-ref',
 		($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
 		'--format=%(objectname) %(refname) %(subject)%00%(committer)',
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 11/14] gitweb: git_is_head_detached() function
  2007-08-31 11:19                     ` [PATCH 10/14] gitweb: display HEAD in heads list when detached Giuseppe Bilotta
@ 2007-08-31 11:19                       ` Giuseppe Bilotta
  2007-08-31 11:19                         ` [PATCH 12/14] gitweb: add HEAD to list of shortlog refs if detached Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

The function checks if the HEAD for the current project is detached by checking if 'git branch' returns "* (no branch)"

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e743c3d..a745434 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1416,6 +1416,13 @@ sub git_get_head_hash {
 	return $retval;
 }
 
+# check if current HEAD is detached
+sub git_is_head_detached {
+	my @x = (git_cmd(), 'branch');
+	my @ret = split("\n", qx(@x));
+	return 0 + grep { /^* \(no branch\)$/ } @ret;
+}
+
 # get type of given object
 sub git_get_type {
 	my $hash = shift;
@@ -2091,11 +2098,9 @@ sub git_get_heads_list {
 	my @headslist;
 
 	if (grep { $_ eq 'heads' } @class) {
-		my @x = (git_cmd(), 'branch');
-		my @ret = split("\n", qx(@x));
-		if (grep { /^* \(no branch\)$/ } @ret) { ;
+		if (git_is_head_detached()) { ;
 			my %ref_item;
-			@x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
+			my @x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
 			my ($hash, $epoch, $title) = split("\n", qx(@x), 3);
 
 			$ref_item{'class'} = 'head';
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 12/14] gitweb: add HEAD to list of shortlog refs if detached
  2007-08-31 11:19                       ` [PATCH 11/14] gitweb: git_is_head_detached() function Giuseppe Bilotta
@ 2007-08-31 11:19                         ` Giuseppe Bilotta
  2007-08-31 11:19                           ` [PATCH 13/14] gitweb: CSS style and refs mark for detached HEAD Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a745434..4f7b7da 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1688,6 +1688,10 @@ sub git_get_last_activity {
 sub git_get_references {
 	my $type = shift || "";
 	my %refs;
+	if (git_is_head_detached()) {
+		my $hash = git_get_head_hash($project);
+		$refs{$hash} = [ 'HEAD' ];
+	}
 	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
 	# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
 	open my $fd, "-|", git_cmd(), "show-ref", "--dereference",
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 13/14] gitweb: CSS style and refs mark for detached HEAD
  2007-08-31 11:19                         ` [PATCH 12/14] gitweb: add HEAD to list of shortlog refs if detached Giuseppe Bilotta
@ 2007-08-31 11:19                           ` Giuseppe Bilotta
  2007-08-31 11:19                             ` [PATCH 14/14] gitweb: minor whitespace cleanups Giuseppe Bilotta
  0 siblings, 1 reply; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index c36b20a..59ca071 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -498,6 +498,11 @@ span.refs span.head {
 	border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
 }
 
+span.refs span.detached {
+	background-color: #ffaaaa;
+	border-color: #ccffcc #00cc33 #00cc33 #ccffcc;
+}
+
 span.atnight {
 	color: #cc0000;
 }
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4f7b7da..2c8a665 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1690,7 +1690,7 @@ sub git_get_references {
 	my %refs;
 	if (git_is_head_detached()) {
 		my $hash = git_get_head_hash($project);
-		$refs{$hash} = [ 'HEAD' ];
+		$refs{$hash} = [ 'detached/HEAD' ];
 	}
 	# 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
 	# c39ae07f393806ccf406ef966e9a15afc43cc36a refs/tags/v2.6.11^{}
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 14/14] gitweb: minor whitespace cleanups
  2007-08-31 11:19                           ` [PATCH 13/14] gitweb: CSS style and refs mark for detached HEAD Giuseppe Bilotta
@ 2007-08-31 11:19                             ` Giuseppe Bilotta
  0 siblings, 0 replies; 25+ messages in thread
From: Giuseppe Bilotta @ 2007-08-31 11:19 UTC (permalink / raw)
  To: git; +Cc: Giuseppe Bilotta

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 gitweb/gitweb.perl |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2c8a665..a767763 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2098,11 +2098,11 @@ sub git_get_heads_list {
 		my ($remote_heads) = gitweb_check_feature('remote_heads');
 		@class = ('heads', $remote_heads ? 'remotes' : undef);
 	}
-	my @refs = map { "refs/$_" } @class ;
+	my @refs = map { "refs/$_" } @class;
 	my @headslist;
 
 	if (grep { $_ eq 'heads' } @class) {
-		if (git_is_head_detached()) { ;
+		if (git_is_head_detached()) {
 			my %ref_item;
 			my @x = (git_cmd(), 'log', '-1', '--pretty=format:%H%n%ct%n%s');
 			my ($hash, $epoch, $title) = split("\n", qx(@x), 3);
@@ -2449,7 +2449,7 @@ sub git_footer_html {
 		print $cgi->a({-href => href(project=>undef, action=>"project_index"),
 		              -class => "rss_logo"}, "TXT") . "\n";
 	}
-	print "</div>\n" ;
+	print "</div>\n";
 
 	if (-f $site_footer) {
 		open (my $fd, $site_footer);
-- 
1.5.2.5

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2007-08-31 11:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27 22:24 gitweb and remote branches Giuseppe Bilotta
2007-08-27 23:29 ` Jakub Narebski
     [not found] ` <cb7bb73a0708280253y7d31f347yb84a40982d59d9d2@mail.gmail.com>
     [not found]   ` <cb7bb73a0708280453k4315e80ej170238a52e66dcb6@mail.gmail.com>
2007-08-29 22:01     ` Jakub Narebski
2007-08-30  7:18       ` Giuseppe Bilotta
2007-08-30  8:16         ` Jakub Narebski
2007-08-30  9:09           ` Giuseppe Bilotta
2007-08-30 21:07           ` Junio C Hamano
2007-08-30 23:09             ` Giuseppe Bilotta
2007-08-30 23:53               ` Jakub Narebski
2007-08-30 23:59                 ` Giuseppe Bilotta
2007-08-31  2:15                   ` Giuseppe Bilotta
2007-08-31 10:54                     ` [PATCH 01/14] gitweb: get remotes too when getting heads list Giuseppe Bilotta
2007-08-31 10:55                     ` [PATCH 02/14] gitweb: make remote heads in heads list optional Giuseppe Bilotta
2007-08-31 10:55                     ` [PATCH 03/14] gitweb: git_get_heads_list now accepts an optional list of refs Giuseppe Bilotta
2007-08-31 10:55                     ` [PATCH 04/14] gitweb: separate heads and remotes list in summary view Giuseppe Bilotta
2007-08-31 10:59                     ` [PATCH 05/14] gitweb: allow refs passed to git_heads_body to use a name different from the hash name Giuseppe Bilotta
2007-08-31 11:05                     ` [PATCH 06/14] gitweb: git_split_heads_body function Giuseppe Bilotta
2007-08-31 11:18                     ` [PATCH 07/14] gitweb: use CSS to style split head lists Giuseppe Bilotta
2007-08-31 11:18                       ` [PATCH 08/14] gitweb: add 'remotes' action as a synonym for git_heads() Giuseppe Bilotta
2007-08-31 11:18                         ` [PATCH 09/14] gitweb: split heads list in head view if appropriate Giuseppe Bilotta
2007-08-31 11:19                     ` [PATCH 10/14] gitweb: display HEAD in heads list when detached Giuseppe Bilotta
2007-08-31 11:19                       ` [PATCH 11/14] gitweb: git_is_head_detached() function Giuseppe Bilotta
2007-08-31 11:19                         ` [PATCH 12/14] gitweb: add HEAD to list of shortlog refs if detached Giuseppe Bilotta
2007-08-31 11:19                           ` [PATCH 13/14] gitweb: CSS style and refs mark for detached HEAD Giuseppe Bilotta
2007-08-31 11:19                             ` [PATCH 14/14] gitweb: minor whitespace cleanups Giuseppe Bilotta

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).