gitweb and remote branches
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.
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Quoted 10 lines · Giuseppe Bilotta
Quoted 5 lines · Giuseppe Bilotta
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.
gitweb.cgi-my
Quoted 5 lines
Signature · 1 line
Giuseppe "Oblomov" Bilottagitweb.cgi-my renamed from gitweb.cgi +0
-0
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.
[...]
gitweb.cgi-my sub git_get_heads_list { · line 1685
Quoted 11 lines
gitweb.cgi-my renamed from gitweb.cgi +2
-1@@ -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
Quoted 14 lines
gitweb.cgi-my renamed from gitweb.cgi +3
-0+ $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",
Quoted 2 lines
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
Signature · 2 lines
Jakub Narebski Poland
Quoted 2 lines · Jakub Narebski
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 :)
Quoted 4 lines
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.
Quoted 5 lines
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.
Quoted 8 lines
gitweb.cgi-my 2007-08-28 13:47:15.000000000 +0200
Quoted 4 lines
Giuseppe "Oblomov" Bilotta
gitweb.cgi-my 2007-08-28 13:47:15.000000000 +0200 renamed from gitweb.cgi 2007-08-26 12:41:13.000000000 +0200 +0
-0It 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.
Quoted 17 lines
Quoted 11 lines
gitweb.cgi-my 2007-08-28 13:47:15.000000000 +0200 renamed from gitweb.cgi 2007-08-26 12:41:13.000000000 +0200 +2
-0@@ -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",Quoted 2 lines
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.
Quoted 3 lines
"<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.
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Quoted 9 lines · Giuseppe Bilotta
Quoted 4 lines · Jakub Narebski
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.
Quoted 3 lines
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 | treeand 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.
Quoted 4 lines
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.
Quoted 9 lines
Quoted 6 lines
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/
Quoted 3 lines
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).
Quoted 2 lines
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[...]
Quoted 5 lines
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
Signature · 2 lines
Jakub Narebski Poland
Quoted 3 lines · Jakub Narebski
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.
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Jakub Narebski
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.
Quoted 9 lines
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:
Quoted 4 lines
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?
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Quoted 6 lines · Giuseppe Bilotta
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Jakub Narebski
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.
[...]
Quoted 9 lines
Quoted 4 lines
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.
Signature · 2 lines
Jakub Narebski Poland
Quoted 10 lines · Jakub Narebski
Quoted 4 lines · Giuseppe Bilotta
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 ...
Signature · 1 line
Giuseppe "Oblomov" Bilotta
Quoted 11 lines · Giuseppe Bilotta
Quoted 10 lines · Jakub Narebski
Quoted 4 lines · Giuseppe Bilotta
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,
Signature · 1 line
Giuseppe "Oblomov" Bilotta
PATCH 1/14 gitweb: get remotes too when getting heads list
--- gitweb/gitweb.perl | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
gitweb/gitweb.perl +3 -2
@@ -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)';
Signature · 1 line
1.5.2.5
PATCH 2/14 gitweb: make remote heads in heads list optional
In reply to Giuseppe Bilotta--- gitweb/gitweb.perl | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +27 -1
@@ -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;
Signature · 1 line
1.5.2.5
PATCH 3/14 gitweb: git_get_heads_list now accepts an optional list of refs.
In reply to Giuseppe Bilottagit_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.
--- gitweb/gitweb.perl | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +7 -4
@@ -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;
Signature · 1 line
1.5.2.5
PATCH 4/14 gitweb: separate heads and remotes list in summary view
In reply to Giuseppe Bilotta--- gitweb/gitweb.perl | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +10 -1
@@ -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,
Signature · 1 line
1.5.2.5
PATCH 5/14 gitweb: allow refs passed to git_heads_body to use a name different from the hash name
In reply to Giuseppe Bilotta--- gitweb/gitweb.perl | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
gitweb/gitweb.perl +7 -5
@@ -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>"; }
Signature · 1 line
1.5.2.5
PATCH 6/14 gitweb: git_split_heads_body function.
In reply to Giuseppe BilottaThe 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.
--- gitweb/gitweb.perl | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +32 -1
@@ -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")}, "...")); }
Signature · 1 line
1.5.2.5
PATCH 7/14 gitweb: use CSS to style split head lists.
In reply to Giuseppe BilottaIntroduce a new div class 'subsection' in the CSS and use it to style split head lists.
--- gitweb/gitweb.css | 10 ++++++++++ gitweb/gitweb.perl | 4 +++- 2 files changed, 13 insertions(+), 1 deletions(-)
gitweb/gitweb.css +10 -0
@@ -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; }
gitweb/gitweb.perl +3 -1
@@ -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"; } }
Signature · 1 line
1.5.2.5
PATCH 8/14 gitweb: add 'remotes' action as a synonym for git_heads()
--- gitweb/gitweb.perl | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +1 -0
@@ -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,
Signature · 1 line
1.5.2.5
PATCH 9/14 gitweb: split heads list in head view if appropriate
--- gitweb/gitweb.perl | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +3 -0
@@ -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();
Signature · 1 line
1.5.2.5
PATCH 10/14 gitweb: display HEAD in heads list when detached
In reply to Giuseppe Bilotta--- gitweb/gitweb.perl | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +21 -0
@@ -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)',
Signature · 1 line
1.5.2.5
PATCH 11/14 gitweb: git_is_head_detached() function
The function checks if the HEAD for the current project is detached by checking if 'git branch' returns "* (no branch)"
--- gitweb/gitweb.perl | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
gitweb/gitweb.perl +9 -4
@@ -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';
Signature · 1 line
1.5.2.5
PATCH 12/14 gitweb: add HEAD to list of shortlog refs if detached
--- gitweb/gitweb.perl | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +4 -0
@@ -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",
Signature · 1 line
1.5.2.5
PATCH 13/14 gitweb: CSS style and refs mark for detached HEAD
--- gitweb/gitweb.css | 5 +++++ gitweb/gitweb.perl | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-)
gitweb/gitweb.css +5 -0
@@ -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; }
gitweb/gitweb.perl +1 -1
@@ -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^{}
Signature · 1 line
1.5.2.5
PATCH 14/14 gitweb: minor whitespace cleanups
--- gitweb/gitweb.perl | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +3 -3
@@ -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);
Signature · 1 line
1.5.2.5
Quoted 9 lines · Jakub Narebski
Quoted 2 lines · Giuseppe Bilotta
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.
Quoted 5 lines
Quoted 3 lines
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.
Quoted 16 lines
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
Quoted 1 line
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.
Quoted 2 lines
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.
Quoted 3 lines
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 :)
Quoted 11 lines
Quoted 4 lines
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.
Quoted 6 lines
Quoted 3 lines
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.
Quoted 7 lines
Quoted 5 lines
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.
Signature · 1 line
Giuseppe "Oblomov" Bilotta
[Cc: Giuseppe Bilotta <[email protected]>, [email protected]]
Quoted 5 lines · Giuseppe Bilotta
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...
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git