$data = $old_data;
}
+function parse_commit($commit_data) {
+ $commit = array();
+ $rev_lines = explode("\n", str_replace("\r", "", $commit_data));
+ $commit['id'] = $rev_lines[0];
+ foreach($rev_lines as $rev_line) {
+ if(substr($rev_line, 0, 4) == " ") {
+ if($commit['text'])
+ $commit['text'] .= "\n";
+ $commit['text'] .= substr($rev_line, 4);
+ } else {
+ $opt = explode(" ", $rev_line);
+ if($opt[0] == "tree")
+ $commit['tree'] = $opt[1];
+ else if($opt[0] == "parent")
+ $commit['parent'][] = $opt[1];
+ else if($opt[0] == "author") {
+ $commit['author'] = $opt[1];
+ $commit['author_mail'] = $opt[2];
+ $commit['author_time'] = $opt[3];
+ } else if($opt[0] == "committer") {
+ $commit['committer'] = $opt[1];
+ $commit['committer_mail'] = $opt[2];
+ $commit['committer_time'] = $opt[3];
+ }
+ }
+ }
+ return $commit;
+}
+
//load rev-list
if(!$data['commits']) {
- $cmd = "git --git-dir=".$repo_path.$project." rev-list --header --max-count=".($_GET['to'] + 1)." ".$_GET['h'];
+ $cmd = "git --git-dir=".$repo_path.$project." rev-list --header --max-count=".($_GET['to'] + 1)." ".($_GET['h'] =="all" ? "--all" : $_GET['h']);
$rev_list = shell_exec($cmd);
foreach(explode("\000", $rev_list) as $rev) {
- $commit = array();
- $rev_lines = explode("\n", str_replace("\r", "", $rev));
- $commit['id'] = $rev_lines[0];
- foreach($rev_lines as $rev_line) {
- if(substr($rev_line, 0, 4) == " ") {
- if($commit['text'])
- $commit['text'] .= "\n";
- $commit['text'] .= substr($rev_line, 4);
- } else {
- $opt = explode(" ", $rev_line);
- if($opt[0] == "tree")
- $commit['tree'] = $opt[1];
- else if($opt[0] == "parent")
- $commit['parent'][] = $opt[1];
- else if($opt[0] == "author") {
- $commit['author'] = $opt[1];
- $commit['author_mail'] = $opt[2];
- $commit['author_time'] = $opt[3];
- } else if($opt[0] == "committer") {
- $commit['committer'] = $opt[1];
- $commit['committer_mail'] = $opt[2];
- $commit['committer_time'] = $opt[3];
- }
- }
- }
- $data['commits'][] = $commit;
+ $data['commits'][] = parse_commit($rev);
}
}
$graph_commit = NULL;
$first_commit = true;
+if($_GET['h'] == "all") {
+ //set master branch as first branch
+ $cmd = "git --git-dir=".$repo_path.$project." rev-list --header --max-count=1 HEAD";
+ $head_list = shell_exec($cmd);
+ $head = parse_commit($head_list);
+ $first_commit = false;
+ $data['branches'][0] = array();
+ $branch = &$data['branches'][0];
+ $branch['id'] = $brach_id++;
+ $branch['uid'] = $branch_uid++;
+ $branch['active'] = true;
+ $branch['next'] = $head['id'];
+}
+
for($i = 0; $i <= intval($_GET['to']); $i++) {
//for($i = 0; $i < count($data['commits']); $i++) {
$commit = &$data['commits'][$i];
}
}
unset($cbranch);
- if($first)
- continue;
+ if($first) {
+ $data['branches'][count($data['branches'])] = array();
+ $branch = &$data['branches'][count($data['branches'])-1];
+ $branch['id'] = $brach_id++;
+ $branch['uid'] = $branch_uid++;
+ $branch['active'] = true;
+ }
}
if(count($commit['parent']) > 1) {
---- index.cgi Wed Aug 29 01:30:10 2012
-+++ index-graph.cgi Wed Aug 29 00:35:09 2012
-@@ -4769,8 +4772,18 @@
+--- index.cgi 2012-08-29 01:30:10 +0000
++++ index-graph.cgi 2012-09-06 11:08:23 +0000
+@@ -4764,13 +4768,26 @@
+
+ sub git_shortlog_body {
+ # uses global variable $project
+- my ($commitlist, $from, $to, $refs, $extra) = @_;
++ my ($commitlist, $from, $to, $refs, $extra, $file_name, $file_hash, $ftype, $allrefs) = @_;
+
$from = 0 unless defined $from;
$to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);
+ my $graph_rand = int(rand(99999));
+
+ my $head = git_get_head_hash($project);
++ if (defined $allrefs && $allrefs == 1) {
++ $hash = "all";
++ }
+ if (!defined $hash) {
+ $hash = $head;
+ }
for (my $i = $from; $i <= $to; $i++) {
my %co = %{$commitlist->[$i]};
my $commit = $co{'id'};
-@@ -4781,6 +4794,7 @@
+@@ -4781,6 +4798,7 @@
print "<tr class=\"light\">\n";
}
$alternate ^= 1;
# git_summary() used print "<td><i>$co{'age_string'}</i></td>\n" .
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
format_author_html('td', \%co, 10) . "<td>";
+@@ -5167,12 +5187,12 @@
+
+ # we need to request one more than 16 (0..15) to check if
+ # those 16 are all
+- my @commitlist = $head ? parse_commits($head, 17) : ();
++ my @commitlist = $head ? parse_commits("--all", 17) : ();
+ if (@commitlist) {
+ git_print_header_div('shortlog');
+ git_shortlog_body(\@commitlist, 0, 15, $refs,
+ $#commitlist <= 15 ? undef :
+- $cgi->a({-href => href(action=>"shortlog")}, "..."));
++ $cgi->a({-href => href(action=>"shortlog")}, "..."), 0, 0, 0, 1);
+ }
+
+ if (@taglist) {
+@@ -5847,8 +5867,10 @@
+ my ($fmt_name, $body_subr, $base, $parent, $file_name, $file_hash) = @_;
+
+ my $head = git_get_head_hash($project);
++ my $allrefs;
+ if (!defined $base) {
+ $base = $head;
++ $allrefs = 1;
+ }
+ if (!defined $page) {
+ $page = 0;
+@@ -5856,7 +5878,10 @@
+ my $refs = git_get_references();
+
+ my $commit_hash = $base;
+- if (defined $parent) {
++ if (defined $allrefs) {
++ $commit_hash = "--all";
++ }
++ if (defined $parent) {
+ $commit_hash = "$parent..$base";
+ }
+ my @commitlist =
+@@ -5912,7 +5937,7 @@
+ if (defined $file_name);
+
+ $body_subr->(\@commitlist, 0, 99, $refs, $next_link,
+- $file_name, $file_hash, $ftype);
++ $file_name, $file_hash, $ftype, $allrefs);
+
+ git_footer_html();
+ }