From bafe8d1bbdb25c6b1c102716b92a5fb890b4938a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Jan 2021 09:06:02 -0800 Subject: [PATCH] Correct Git repository browse behavior for differences in "ls-tree" output Summary: Ref T13589. The output for "git ls-tree commit:path" (the old invocation) and "git ls-tree commit -- path" (the new invocation) differs: the latter emits absolute paths. Update the code to account for this difference in behavior. Test Plan: - Browsed a non-root directory in a Git repository in Diffusion. - Before: saw absolute paths. - After: saw relative paths. Maniphest Tasks: T13589 Differential Revision: https://secure.phabricator.com/D21519 --- .../DiffusionBrowseQueryConduitAPIMethod.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php index 49a34ac250..4402c2a5d0 100644 --- a/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php @@ -138,12 +138,6 @@ final class DiffusionBrowseQueryConduitAPIMethod $submodules = array(); - if ($path !== null) { - $prefix = rtrim($path, '/').'/'; - } else { - $prefix = ''; - } - $count = 0; $results = array(); $lines = empty($stdout) @@ -166,7 +160,7 @@ final class DiffusionBrowseQueryConduitAPIMethod $line)); } - list($mode, $type, $hash, $size, $name) = $parts; + list($mode, $type, $hash, $size, $full_path) = $parts; $path_result = new DiffusionRepositoryPath(); @@ -184,8 +178,14 @@ final class DiffusionBrowseQueryConduitAPIMethod } } - $path_result->setFullPath($prefix.$name); - $path_result->setPath($name); + if ($path === null) { + $local_path = $full_path; + } else { + $local_path = basename($full_path); + } + + $path_result->setFullPath($full_path); + $path_result->setPath($local_path); $path_result->setHash($hash); $path_result->setFileType($file_type); $path_result->setFileSize($size);