├── contrib └── diff.php ├── examples └── git_http_client.php ├── git_graph.php ├── gitweb ├── index.php ├── prettify.css └── prettify.js └── phpgit ├── git.php ├── gitbase.php ├── gitcheckout.php ├── gitclone.php ├── githttpclone.php └── http.php /contrib/diff.php: -------------------------------------------------------------------------------- 1 | 6 | Copyright (C) 2005 Nils Knappmeier next version 7 | 8 | This program is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License 10 | as published by the Free Software Foundation; either version 2 11 | of the License, or (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | 22 | http://www.gnu.org/licenses/gpl.html 23 | 24 | About: 25 | I searched a function to compare arrays and the array_diff() 26 | was not specific enough. It ignores the order of the array-values. 27 | So I reimplemented the diff-function which is found on unix-systems 28 | but this you can use directly in your code and adopt for your needs. 29 | Simply adopt the formatline-function. with the third-parameter of arr_diff() 30 | you can hide matching lines. Hope someone has use for this. 31 | 32 | Contact: d.u.diff@holomind.de 33 | **/ 34 | 35 | 36 | ## PHPDiff returns the differences between $old and $new, formatted 37 | ## in the standard diff(1) output format. 38 | function PHPDiff($old,$new) 39 | { 40 | # split the source text into arrays of lines 41 | $t1 = explode("\n",$old); 42 | $x=array_pop($t1); 43 | if ($x>'') $t1[]="$x\n\\ No newline at end of file"; 44 | $t2 = explode("\n",$new); 45 | $x=array_pop($t2); 46 | if ($x>'') $t2[]="$x\n\\ No newline at end of file"; 47 | 48 | # build a reverse-index array using the line as key and line number as value 49 | # don't store blank lines, so they won't be targets of the shortest distance 50 | # search 51 | foreach($t1 as $i=>$x) if ($x>'') $r1[$x][]=$i; 52 | foreach($t2 as $i=>$x) if ($x>'') $r2[$x][]=$i; 53 | 54 | $a1=0; $a2=0; # start at beginning of each list 55 | $actions=array(); 56 | 57 | # walk this loop until we reach the end of one of the lists 58 | while ($a1=$s1) { $d=$n; break; } 70 | if ($d>=$s1 && ($d+$s2-$a1-$a2)<($best1+$best2-$a1-$a2)) 71 | { $best1=$d; $best2=$s2; } 72 | $d=-1; 73 | foreach((array)@$r2[$t1[$s1]] as $n) 74 | if ($n>=$s2) { $d=$n; break; } 75 | if ($d>=$s2 && ($s1+$d-$a1-$a2)<($best1+$best2-$a1-$a2)) 76 | { $best1=$s1; $best2=$d; } 77 | $s1++; $s2++; 78 | } 79 | while ($a1<$best1) { $actions[]=1; $a1++; } # deleted elements 80 | while ($a2<$best2) { $actions[]=2; $a2++; } # added elements 81 | } 82 | 83 | # we've reached the end of one list, now walk to the end of the other 84 | while($a10) { 99 | $xstr = ($x1==($x0+1)) ? $x1 : ($x0+1).",$x1"; 100 | $ystr = ($y1==($y0+1)) ? $y1 : ($y0+1).",$y1"; 101 | if ($op==1) $out[] = "{$xstr}d{$y1}"; 102 | elseif ($op==3) $out[] = "{$xstr}c{$ystr}"; 103 | while ($x0<$x1) { $out[] = '< '.$t1[$x0]; $x0++; } # deleted elems 104 | if ($op==2) $out[] = "{$x1}a{$ystr}"; 105 | elseif ($op==3) $out[] = '---'; 106 | while ($y0<$y1) { $out[] = '> '.$t2[$y0]; $y0++; } # added elems 107 | } 108 | $x1++; $x0=$x1; 109 | $y1++; $y0=$y1; 110 | $op=0; 111 | } 112 | $out[] = ''; 113 | return join("\n",$out); 114 | } 115 | 116 | ?> 117 | -------------------------------------------------------------------------------- /examples/git_http_client.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crodas/php-git/cc4e3167d61941d053f9857a8d79c5556153e576/examples/git_http_client.php -------------------------------------------------------------------------------- /git_graph.php: -------------------------------------------------------------------------------- 1 | branch as $branch => $id) { 13 | $history[$branch] = $this->getHistory($branch); 14 | } 15 | $this->modInit(); 16 | } 17 | 18 | protected function setImageSize($width,$height) { 19 | $this->width = $width; 20 | $this->height = $height; 21 | } 22 | 23 | abstract function modInit(); 24 | abstract function addBranchName(); 25 | } 26 | 27 | require("contrib/pChart.1.27/pChart/pData.class"); 28 | require("contrib/pChart.1.27/pChart/pChart.class"); 29 | 30 | 31 | final class Git_Graphic_pChart extends Git_Graphic 32 | { 33 | private $_pchart; 34 | private $_data; 35 | private $_height; 36 | private $_width; 37 | 38 | function modInit() { 39 | $this->_data = new pData; 40 | $this->_pchart = new pChart($this->height,$this->width); 41 | } 42 | 43 | function addBranchName() { 44 | } 45 | 46 | } 47 | 48 | 49 | $git_graph = new Git_Graphic_pChart(".git"); 50 | $git_graph->doGraphic(); 51 | 52 | ?> 53 | -------------------------------------------------------------------------------- /gitweb/index.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crodas/php-git/cc4e3167d61941d053f9857a8d79c5556153e576/gitweb/index.php -------------------------------------------------------------------------------- /gitweb/prettify.css: -------------------------------------------------------------------------------- 1 | .str{color:#080} 2 | .kwd{color:#008} 3 | .com{color:#800} 4 | .typ{color:#606} 5 | .lit{color:#066} 6 | .pun{color:#660} 7 | .pln{color:#000} 8 | .tag{color:#008} 9 | .atn{color:#606} 10 | .atv{color:#080} 11 | .dec{color:#606 12 | .prettyprint{padding:2px;border:1px solid #888, overflow:auto} 13 | 14 | @media print{.str{color:#060} 15 | .kwd{color:#006;font-weight:bold} 16 | .com{color:#600;font-style:italic} 17 | .typ{color:#404;font-weight:bold} 18 | .lit{color:#044} 19 | .pun{color:#440} 20 | .pln{color:#000} 21 | .tag{color:#006;font-weight:bold} 22 | .atn{color:#404} .atv{color:#060} } 23 | -------------------------------------------------------------------------------- /gitweb/prettify.js: -------------------------------------------------------------------------------- 1 | (function(){var x={};(function(){var c=["abstract bool break case catch char class const const_cast continue default delete deprecated dllexport dllimport do double dynamic_cast else enum explicit extern false float for friend goto if inline int long mutable naked namespace new noinline noreturn nothrow novtable operator private property protected public register reinterpret_cast return selectany short signed sizeof static static_cast struct switch template this thread throw true try typedef typeid typename union unsigned using declaration, directive uuid virtual void volatile while typeof", 2 | "as base by byte checked decimal delegate descending event finally fixed foreach from group implicit in interface internal into is lock null object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var","package synchronized boolean implements import throws instanceof transient extends final strictfp native super","debugger export function with NaN Infinity","require sub unless until use elsif BEGIN END","and assert def del elif except exec global lambda not or pass print raise yield False True None", 3 | "then end begin rescue ensure module when undef next redo retry alias defined","done fi"];for(var a=0;a="a"&&c<="z"||c>="A"&&c<="Z"}function q(c,a,b,d){c.unshift(b,d||0);try{a.splice.apply(a,c)}finally{c.splice(0,2)}}var R=(function(){var c=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===", 4 | ">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=","~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"],a="(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)";for(var b=0;b:&])/g,"\\$1")}}a+="|^)\\s*$";return new RegExp(a)})(),y=/&/g,A=//g,$=/\"/g;function v(c){return c.replace(y,"&").replace(A, 5 | "<").replace(z,">")}var Z=/</g,Y=/>/g,T=/'/g,aa=/"/g,S=/&/g;function I(c){var a=c.indexOf("&");if(a<0){return c}for(--a;(a=c.indexOf("&#",a+1))>=0;){var b=c.indexOf(";",a);if(b>=0){var d=c.substring(a+3,b),g=10;if(d&&d.charAt(0)=="x"){d=d.substring(1);g=16}var e=parseInt(d,g);if(!isNaN(e)){c=c.substring(0,a)+String.fromCharCode(e)+c.substring(b+1)}}}return c.replace(Z,"<").replace(Y,">").replace(T,"'").replace(aa,'"').replace(S,"&")}function w(c){return"XMP"==c.tagName}var t= 6 | null;function H(c){if(null===t){var a=document.createElement("PRE");a.appendChild(document.createTextNode('\n'));t=!/"); 7 | for(var e=c.firstChild;e;e=e.nextSibling){u(e,a)}if(c.firstChild||!/^(?:br|link|img)$/.test(b)){a.push("")}break;case 2:a.push(c.name.toLowerCase(),'="',c.value.replace(y,"&").replace(A,"<").replace(z,">").replace($,"""),'"');break;case 3:case 4:a.push(v(c.nodeValue));break}}function P(c){var a=0;return function(b){var d=null,g=0;for(var e=0,i=b.length;e=0;h-=" ".length){d.push(" ".substring(0, 8 | h))}g=e+1;break;case "\n":a=0;break;default:++a}}if(!d){return b}d.push(b.substring(g));return d.join("")}}var W=/(?:[^<]+|