From f4fa968770821b73983460735d6127f08af7f292 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 21 Nov 2012 16:56:05 -0800 Subject: [PATCH] Fix an issue with browsing repositories that have README, etc Summary: D3533 changed the path for files at root from, e.g., "README" to "/README", which fatals when we try to `git cat-file` it. Test Plan: This no longer happens: {F24874} Viewed a directory in browse without a trailing slash in the URL. Reviewers: vrana, nh Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D4016 --- .../diffusion/query/browse/DiffusionGitBrowseQuery.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/applications/diffusion/query/browse/DiffusionGitBrowseQuery.php b/src/applications/diffusion/query/browse/DiffusionGitBrowseQuery.php index 28fab2d3a0..3f6c81c76f 100644 --- a/src/applications/diffusion/query/browse/DiffusionGitBrowseQuery.php +++ b/src/applications/diffusion/query/browse/DiffusionGitBrowseQuery.php @@ -60,6 +60,12 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery { $submodules = array(); + if (strlen($path)) { + $prefix = rtrim($path, '/').'/'; + } else { + $prefix = ''; + } + $results = array(); foreach (explode("\0", rtrim($stdout)) as $line) { @@ -83,7 +89,7 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery { } } - $result->setFullPath(rtrim($path, '/').'/'.$name); + $result->setFullPath($prefix.$name); $result->setPath($name); $result->setHash($hash); $result->setFileType($file_type);