From 791ff588a81481f5c6807f349110279047cb6819 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 5 May 2012 20:21:21 +0200 Subject: [PATCH] Save reference to repository in each object --- public_html/libgit/class.commit.php | 4 ++-- public_html/libgit/class.object.php | 4 +++- public_html/libgit/class.repository.php | 10 +++++----- public_html/test.php | 1 + 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public_html/libgit/class.commit.php b/public_html/libgit/class.commit.php index a7f7f4e..f120993 100644 --- a/public_html/libgit/class.commit.php +++ b/public_html/libgit/class.commit.php @@ -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(); diff --git a/public_html/libgit/class.object.php b/public_html/libgit/class.object.php index c77f33f..7596701 100644 --- a/public_html/libgit/class.object.php +++ b/public_html/libgit/class.object.php @@ -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; } diff --git a/public_html/libgit/class.repository.php b/public_html/libgit/class.repository.php index 001602e..b47cf18 100644 --- a/public_html/libgit/class.repository.php +++ b/public_html/libgit/class.repository.php @@ -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; } } diff --git a/public_html/test.php b/public_html/test.php index 77d90c2..0508c2a 100644 --- a/public_html/test.php +++ b/public_html/test.php @@ -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"));