Skip empty lines in tree

master
Sven Slootweg 12 years ago
parent 76602755be
commit 70e411941f

@ -41,10 +41,13 @@ class GitTree extends GitObject
foreach($lines as $line)
{
list($metadata, $binhash) = explode("\0", $line, 2);
list($mode, $filename) = explode(" ", $metadata, 2);
$hash = sha1_from_bin($binhash);
$this->elements[] = new GitTreeElement($mode, $filename, $hash);
if(!empty($line))
{
list($metadata, $binhash) = explode("\0", $line, 2);
list($mode, $filename) = explode(" ", $metadata, 2);
$hash = sha1_from_bin($binhash);
$this->elements[] = new GitTreeElement($mode, $filename, $hash);
}
}
}
}

@ -2,7 +2,7 @@
require("libgit/base.php");
$repo = new GitRepository("/home/occupy/testrepo.git");
pretty_dump($repo->GetTag("1.0")->GetCommit());
pretty_dump($repo->GetTag("1.0")->GetTree());
/*pretty_dump($s->GetObject("54e03e490b1bee1c154c3545bf258cab0629ee02"));
pretty_dump($s->GetObject("98d99489382a3541e6783bb2083554785f3eb72a"));

Loading…
Cancel
Save