From: pk910 Date: Fri, 7 Sep 2012 05:55:51 +0000 (+0200) Subject: added possibility to show "official branches" up to the first commit X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee7f986fc9fa02f5465b002f83390ce1cd93456e;p=gitweb.git added possibility to show "official branches" up to the first commit --- diff --git a/git_graph.php b/git_graph.php index 006b8a3..ce55b1e 100644 --- a/git_graph.php +++ b/git_graph.php @@ -8,6 +8,8 @@ $size = 20; $tile_size = 20; /* do not edit */ $max_branches = 30; +$use_local_branches = true; +$use_remote_branches = true; $colors = array( NULL, @@ -131,12 +133,61 @@ if($_GET['h'] == "all") { $head_list = shell_exec($cmd); $head = parse_commit($head_list); $first_commit = false; - $data['branches'][0] = array(); - $branch = &$data['branches'][0]; + $data['branches'][count($data['branches'])] = array(); + $branch = &$data['branches'][count($data['branches'])-1]; $branch['id'] = $brach_id++; $branch['uid'] = $branch_uid++; $branch['active'] = true; $branch['next'] = $head['id']; + unset($branch); + if($use_local_branches) { + $cmd = "git --git-dir=".$repo_path.$project." for-each-ref --sort=-committerdate refs/heads/"; + $head_list = shell_exec($cmd); + foreach(explode("\n", str_replace("\r", "", $head_list)) as $head) { + $head = explode(" ", $head); + if(!$head[0]) + continue; + $existing = false; + foreach($data['branches'] as $branch) { + if($branch['next'] == $head[0]) { + $existing = true; + break; + } + } + if($existing) + continue; + $data['branches'][count($data['branches'])] = array( + "id" => $brach_id++, + "uid" => $brach_uid++, + "active" => true, + "next" => $head[0] + ); + } + } + if($use_remote_branches) { + $cmd = "git --git-dir=".$repo_path.$project." for-each-ref --sort=-committerdate refs/remotes/"; + $head_list = shell_exec($cmd); + foreach(explode("\n", str_replace("\r", "", $head_list)) as $head) { + $head = explode(" ", $head); + if(!$head[0]) + continue; + $existing = false; + foreach($data['branches'] as $branch) { + if($branch['next'] == $head[0]) { + $existing = true; + break; + } + } + if($existing) + continue; + $data['branches'][count($data['branches'])] = array( + "id" => $brach_id++, + "uid" => $brach_uid++, + "active" => true, + "next" => $head[0] + ); + } + } } for($i = 0; $i <= intval($_GET['to']); $i++) {