Save reference to repository in each object
This commit is contained in:
parent
bcf3095df8
commit
791ff588a8
|
@ -7,9 +7,9 @@ class GitCommit extends GitObject
|
|||
public $message = "";
|
||||
public $parents = array();
|
||||
|
||||
function __construct($headerdata, $data)
|
||||
function __construct($repo, $headerdata, $data)
|
||||
{
|
||||
parent::__construct($headerdata, $data);
|
||||
parent::__construct($repo, $headerdata, $data);
|
||||
|
||||
$lines = explode("\n", $data);
|
||||
$message_parts = array();
|
||||
|
|
|
@ -3,9 +3,11 @@ class GitObject
|
|||
{
|
||||
public $rawdata = "";
|
||||
public $size = 0;
|
||||
public $repo = null;
|
||||
|
||||
function __construct($headerdata, $data)
|
||||
function __construct($repo, $headerdata, $data)
|
||||
{
|
||||
$this->repo = $repo;
|
||||
$this->size = (int)$headerdata;
|
||||
$this->rawdata = $data;
|
||||
}
|
||||
|
|
|
@ -35,19 +35,19 @@ class GitRepository
|
|||
switch($type)
|
||||
{
|
||||
case "commit":
|
||||
return new GitCommit($headerdata, $data);
|
||||
return new GitCommit($this, $headerdata, $data);
|
||||
break;
|
||||
case "blob":
|
||||
return new GitBlob($headerdata, $data);
|
||||
return new GitBlob($this, $headerdata, $data);
|
||||
break;
|
||||
case "tree":
|
||||
return new GitTree($headerdata, $data);
|
||||
return new GitTree($this, $headerdata, $data);
|
||||
break;
|
||||
case "tag":
|
||||
return new GitTag($headerdata, $data);
|
||||
return new GitTag($this, $headerdata, $data);
|
||||
break;
|
||||
default:
|
||||
return new GitObject($headerdata, $data);
|
||||
return new GitObject($this, $headerdata, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,3 +3,4 @@ require("libgit/base.php");
|
|||
|
||||
$s = new GitRepository("/home/occupy/testrepo.git");
|
||||
pretty_dump($s->GetObject("54e03e490b1bee1c154c3545bf258cab0629ee02"));
|
||||
pretty_dump($s->GetObject("9d8e0ba4a30f6a5d775a879c42c7de5aed4530c6"));
|
||||
|
|
Loading…
Reference in a new issue