Browse Source

Skip empty lines in tree

master
Sven Slootweg 10 years ago
parent
commit
70e411941f
  1. 11
      public_html/libgit/class.tree.php
  2. 2
      public_html/test.php

11
public_html/libgit/class.tree.php

@ -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
public_html/test.php

@ -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