Skip to content

Commit

Permalink
diff output parsing skips empty lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
wimrijnders committed Apr 21, 2013
1 parent fc32fd6 commit 2febca6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/GitList/Git/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 52,11 @@ public function getCommit($commitHash)
. "<body><![CDATA[%b]]></body>"
. "</item>\" $commitHash"
);

$xmlEnd = strpos($logs, '</item>') 7;
$commitInfo = substr($logs, 0, $xmlEnd);
$commitData = substr($logs, $xmlEnd);
$logs = explode("\n", $commitData);
array_shift($logs);

// Read commit metadata
$format = new PrettyFormat;
Expand All @@ -67,8 67,6 @@ public function getCommit($commitHash)
if ($commit->getParentsHash()) {
$command = 'diff ' . $commitHash . '~1..' . $commitHash;
$logs = explode("\n", $this->getClient()->run($this, $command));
} else {
$logs = array_slice($logs, 1);
}

$commit->setDiffs($this->readDiffLogs($logs));
Expand Down Expand Up @@ -126,6 124,11 @@ public function readDiffLogs(array $logs)
$lineNumOld = 0;
$lineNumNew = 0;
foreach ($logs as $log) {
# Skip empty lines
if ($log == "") {
continue;
}

if ('diff' === substr($log, 0, 4)) {
if (isset($diff)) {
$diffs[] = $diff;
Expand Down

0 comments on commit 2febca6

Please sign in to comment.