From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Petr Baudis <pasky@suse.cz>
Cc: Bert Wesarg <bert.wesarg@googlemail.com>, git@vger.kernel.org
Subject: [PATCH] GitWeb + TopGit
Date: Wed, 3 Jun 2009 13:09:12 +0200 [thread overview]
Message-ID: <1244027352-24055-1-git-send-email-bert.wesarg@googlemail.com> (raw)
Hello Petr,
I have changed gitweb to show topgit topics. log and shortlog shows
only the history for refs/top-bases/$topic..$topic.
You can see it in action here:
http://kgb2.thruhere.net/git/?p=bertw/topgit.git;a=summary
This patch is based on the debian package gitweb-1.6.3.1-1. If you'r
interested I can rebase the patch on git.git.
Regards,
Bert
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
diff --git a/gitweb.cgi b/gitweb.cgi
index 820f073..fd9e64b 100755
--- a/gitweb.cgi
+++ b/gitweb.cgi
@@ -536,6 +536,7 @@ our %actions = (
"summary" => \&git_summary,
"tag" => \&git_tag,
"tags" => \&git_tags,
+ "topics" => \&git_topics,
"tree" => \&git_tree,
"snapshot" => \&git_snapshot,
"object" => \&git_object,
@@ -2684,12 +2685,13 @@ sub parse_from_to_diffinfo {
## ......................................................................
## parse to array of hashes functions
-sub git_get_heads_list {
+sub _git_get_heads_list {
+ my $topics = shift;
my $limit = shift;
+ my $n = 0;
my @headslist;
- open my $fd, '-|', git_cmd(), 'for-each-ref',
- ($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
+ open my $fd, '-|', git_cmd(), 'for-each-ref', '--sort=-committerdate',
'--format=%(objectname) %(refname) %(subject)%00%(committer)',
'refs/heads'
or return;
@@ -2704,6 +2706,22 @@ sub git_get_heads_list {
$ref_item{'fullname'} = $name;
$name =~ s!^refs/heads/!!;
+ # filter TopGit topics out
+ open (my $dd, "-|", git_cmd(), 'rev-parse', '--quiet',
+ '--verify', "refs/top-bases/$name")
+ or die_error(500, "Open rev-parse failed");
+ my $base_ref = <$dd>;
+ close $dd;
+ next if ($topics ? !defined $base_ref : defined $base_ref);
+
+ # limit list
+ last if ($limit and $n++ > ($limit + 1));
+
+ if ($topics) {
+ $ref_item{'base_name'} = "refs/top-bases/$name";
+ $ref_item{'base_id'} = $base_ref;
+ }
+
$ref_item{'name'} = $name;
$ref_item{'id'} = $hash;
$ref_item{'title'} = $title || '(no commit message)';
@@ -2721,6 +2739,14 @@ sub git_get_heads_list {
return wantarray ? @headslist : \@headslist;
}
+sub git_get_heads_list {
+ return _git_get_heads_list(0, @_);
+}
+
+sub git_get_topics_list {
+ return _git_get_heads_list(1, @_);
+}
+
sub git_get_tags_list {
my $limit = shift;
my @tagslist;
@@ -4335,6 +4361,53 @@ sub git_heads_body {
print "</table>\n";
}
+sub git_topics_body {
+ # uses global variable $project
+ my ($topiclist, $head, $from, $to, $extra) = @_;
+ $from = 0 unless defined $from;
+ $to = $#{$topiclist} if (!defined $to || $#{$topiclist} < $to);
+
+ print "<table class=\"heads\">\n";
+ my $alternate = 1;
+ for (my $i = $from; $i <= $to; $i++) {
+ my $entry = $topiclist->[$i];
+ my %ref = %$entry;
+ my $curr = $ref{'id'} eq $head;
+ if ($alternate) {
+ print "<tr class=\"dark\">\n";
+ } else {
+ print "<tr class=\"light\">\n";
+ }
+ $alternate ^= 1;
+ print "<td><i>$ref{'age'}</i></td>\n" .
+ ($curr ? "<td class=\"current_head\">" : "<td>") .
+ $cgi->a({-href => href(action=>"shortlog",
+ hash_parent=>$ref{'base_name'},
+ hash=>$ref{'fullname'},
+ extra_options=>'--no-merges'),
+ -class => "list name"},esc_html($ref{'name'})) .
+ "</td>\n" .
+ "<td class=\"link\">" .
+ $cgi->a({-href => href(action=>"shortlog",
+ hash_parent=>$ref{'base_name'},
+ hash=>$ref{'fullname'},
+ extra_options=>'--no-merges')}, "shortlog") . " | " .
+ $cgi->a({-href => href(action=>"log",
+ hash_parent=>$ref{'base_name'},
+ hash=>$ref{'fullname'},
+ extra_options=>'--no-merges')}, "log") . " | " .
+ $cgi->a({-href => href(action=>"tree", hash=>$ref{'fullname'}, hash_base=>$ref{'name'})}, "tree") .
+ "</td>\n" .
+ "</tr>";
+ }
+ if (defined $extra) {
+ print "<tr>\n" .
+ "<td colspan=\"3\">$extra</td>\n" .
+ "</tr>\n";
+ }
+ print "</table>\n";
+}
+
sub git_search_grep_body {
my ($commitlist, $from, $to, $extra) = @_;
$from = 0 unless defined $from;
@@ -4481,6 +4554,7 @@ sub git_summary {
# there are more ...
my @taglist = git_get_tags_list(16);
my @headlist = git_get_heads_list(16);
+ my @topiclist = git_get_topics_list(16);
my @forklist;
my $check_forks = gitweb_check_feature('forks');
@@ -4558,6 +4632,13 @@ sub git_summary {
$cgi->a({-href => href(action=>"heads")}, "..."));
}
+ if (@topiclist) {
+ git_print_header_div('topics');
+ git_topics_body(\@topiclist, $head, 0, 15,
+ $#topiclist <= 15 ? undef :
+ $cgi->a({-href => href(action=>"topics")}, "..."));
+ }
+
if (@forklist) {
git_print_header_div('forks');
git_project_list_body(\@forklist, 'age', 0, 15,
@@ -4757,6 +4838,19 @@ sub git_heads {
git_footer_html();
}
+sub git_topics {
+ my $head = git_get_head_hash($project);
+ git_header_html();
+ git_print_page_nav('','', $head,undef,$head);
+ git_print_header_div('summary', $project);
+
+ my @topicslist = git_get_topics_list();
+ if (@topicslist) {
+ git_topics_body(\@topicslist, $head);
+ }
+ git_footer_html();
+}
+
sub git_blob_plain {
my $type = shift;
my $expires;
@@ -5054,7 +5148,11 @@ sub git_log {
}
my $refs = git_get_references();
- my @commitlist = parse_commits($hash, 101, (100 * $page));
+ my $commit_hash = $hash;
+ if (defined $hash_parent) {
+ $commit_hash = "$hash_parent..$hash";
+ }
+ my @commitlist = parse_commits($commit_hash, 101, (100 * $page));
my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
next reply other threads:[~2009-06-03 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-03 11:09 Bert Wesarg [this message]
2009-11-03 20:39 ` [PATCH] GitWeb + TopGit Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244027352-24055-1-git-send-email-bert.wesarg@googlemail.com \
--to=bert.wesarg@googlemail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).