@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Correct Diffusion browse behavior when visiting a path URI with no trailing slash

Summary:
See PHI1983. Ref T13599. Ref T13589. Currently, if you browse to a path browse URI in Diffusion without a trailing slash (`/browse/master/src`), you get a nonsensical view (the directory as a single item).

Be more precise in how "git ls-tree" arguments are constructed.

Test Plan: Visited files and directories in the browse view, with and without trailing slashes. Saw improved behavior for directories with no trailing slash and reasonable behavior in all other cases.

Maniphest Tasks: T13599, T13589

Differential Revision: https://secure.phabricator.com/D21528

+10 -3
+10 -3
src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
··· 37 37 $repository = $drequest->getRepository(); 38 38 39 39 $path = $request->getValue('path'); 40 - if (!strlen($path)) { 40 + if (!strlen($path) || $path === '/') { 41 41 $path = null; 42 42 } 43 43 ··· 49 49 if ($path === null) { 50 50 // Fast path to improve the performance of the repository view; we know 51 51 // the root is always a tree at any commit and always exists. 52 - $stdout = 'tree'; 52 + $path_type = 'tree'; 53 53 } else { 54 54 try { 55 55 list($stdout) = $repository->execxLocalCommand( 56 56 'cat-file -t -- %s', 57 57 sprintf('%s:%s', $commit, $path)); 58 + $path_type = trim($stdout); 58 59 } catch (CommandException $e) { 59 60 // The "cat-file" command may fail if the path legitimately does not 60 61 // exist, but it may also fail if the path is a submodule. This can ··· 114 115 } 115 116 } 116 117 117 - if (trim($stdout) == 'blob') { 118 + if ($path_type === 'blob') { 118 119 $result->setReasonForEmptyResultSet( 119 120 DiffusionBrowseResultSet::REASON_IS_FILE); 120 121 return $result; ··· 130 131 'ls-tree -z -l %s --', 131 132 gitsprintf('%s', $commit)); 132 133 } else { 134 + if ($path_type === 'tree') { 135 + $path = rtrim($path, '/').'/'; 136 + } else { 137 + $path = rtrim($path, '/'); 138 + } 139 + 133 140 list($stdout) = $repository->execxLocalCommand( 134 141 'ls-tree -z -l %s -- %s', 135 142 gitsprintf('%s', $commit),