From ffd46df597c676428bfdcbee1f9d40e2260ed79e Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 23 Jan 2013 15:11:16 -0800 Subject: [PATCH] Avoid error in blaming empty file Summary: Fixes T2389, resolves TODO. Test Plan: Blamed seemingly binary file. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2389 Differential Revision: https://secure.phabricator.com/D4604 --- .../controller/DiffusionBrowseFileController.php | 2 -- .../query/filecontent/DiffusionFileContentQuery.php | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php index 5b4a00491d..e3f5592426 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php @@ -467,8 +467,6 @@ final class DiffusionBrowseFileController extends DiffusionController { // with same color; otherwise generate blame info. The newer a change // is, the more saturated the color. - // TODO: SVN doesn't always give us blame for the last line, if empty? - // Bug with our stuff or with SVN? $rev = idx($rev_list, $k, $last_rev); if ($last_rev == $rev) { diff --git a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php index 0004dec335..a821dfa32a 100644 --- a/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php +++ b/src/applications/diffusion/query/filecontent/DiffusionFileContentQuery.php @@ -30,17 +30,17 @@ abstract class DiffusionFileContentQuery extends DiffusionQuery { } final public function getBlameData() { - $raw_data = $this->getRawData(); + $raw_data = preg_replace('/\n$/', '', $this->getRawData()); $text_list = array(); $rev_list = array(); $blame_dict = array(); if (!$this->getNeedsBlame()) { - $text_list = explode("\n", rtrim($raw_data)); - } else { + $text_list = explode("\n", $raw_data); + } else if ($raw_data != '') { $lines = array(); - foreach (explode("\n", rtrim($raw_data)) as $k => $line) { + foreach (explode("\n", $raw_data) as $k => $line) { $lines[$k] = $this->tokenizeLine($line); list($rev_id, $author, $text) = $lines[$k];