@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.

If "branch" is provided to "diffusion.branchquery", use it as the "<pattern>" argument to "git branch --contains ..."

Summary:
Ref T13151. See PHI720. If you want to test if commit X appears on specific branch Y, `git branch --contains X -- Y` is faster than (effectively) `git branch --contains X | grep Y`.

Since this call has a "branch" parameter anyway, use it as the pattern argument if provided.

Test Plan:
- Called the API method with no parameters, got all branches.
- Called the API method with `master`, got just master.
- Called the API method with `maste*`, got master. This behavior is not officially supported and may change in the future.
- Viewed a commit, still saw all branches.
- Grepped for `diffusion.branchquery` and verified that no remaining callsites pass a default "branch" parameter.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13151

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

+18 -4
+17 -4
src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
··· 30 30 31 31 $contains = $request->getValue('contains'); 32 32 if (strlen($contains)) { 33 + 34 + // See PHI720. If the standard "branch" field is provided, use it 35 + // as the "pattern" argument to "git branch ..." to let callers test 36 + // for reachability from a particular branch head. 37 + $pattern = $request->getValue('branch'); 38 + if (strlen($pattern)) { 39 + $pattern_argv = array($pattern); 40 + } else { 41 + $pattern_argv = array(); 42 + } 43 + 33 44 // NOTE: We can't use DiffusionLowLevelGitRefQuery here because 34 45 // `git for-each-ref` does not support `--contains`. 35 46 if ($repository->isWorkingCopyBare()) { 36 47 list($stdout) = $repository->execxLocalCommand( 37 - 'branch --verbose --no-abbrev --contains %s --', 38 - $contains); 48 + 'branch --verbose --no-abbrev --contains %s -- %Ls', 49 + $contains, 50 + $pattern_argv); 39 51 $ref_map = DiffusionGitBranch::parseLocalBranchOutput( 40 52 $stdout); 41 53 } else { 42 54 list($stdout) = $repository->execxLocalCommand( 43 - 'branch -r --verbose --no-abbrev --contains %s --', 44 - $contains); 55 + 'branch -r --verbose --no-abbrev --contains %s -- %Ls', 56 + $contains, 57 + $pattern_argv); 45 58 $ref_map = DiffusionGitBranch::parseRemoteBranchOutput( 46 59 $stdout, 47 60 DiffusionGitBranch::DEFAULT_GIT_REMOTE);
+1
src/applications/diffusion/controller/DiffusionCommitBranchesController.php
··· 22 22 array( 23 23 'contains' => $drequest->getCommit(), 24 24 'limit' => $branch_limit + 1, 25 + 'branch' => null, 25 26 ))); 26 27 27 28 $has_more_branches = (count($branches) > $branch_limit);