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
This commit is contained in:
epriestley
2018-06-21 15:24:43 -07:00
parent 6136b83275
commit 8ab8c390b7
2 changed files with 18 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ final class DiffusionCommitBranchesController extends DiffusionController {
array(
'contains' => $drequest->getCommit(),
'limit' => $branch_limit + 1,
'branch' => null,
)));
$has_more_branches = (count($branches) > $branch_limit);