mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
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:
parent
6136b83275
commit
8ab8c390b7
2 changed files with 18 additions and 4 deletions
|
@ -30,18 +30,31 @@ final class DiffusionBranchQueryConduitAPIMethod
|
||||||
|
|
||||||
$contains = $request->getValue('contains');
|
$contains = $request->getValue('contains');
|
||||||
if (strlen($contains)) {
|
if (strlen($contains)) {
|
||||||
|
|
||||||
|
// See PHI720. If the standard "branch" field is provided, use it
|
||||||
|
// as the "pattern" argument to "git branch ..." to let callers test
|
||||||
|
// for reachability from a particular branch head.
|
||||||
|
$pattern = $request->getValue('branch');
|
||||||
|
if (strlen($pattern)) {
|
||||||
|
$pattern_argv = array($pattern);
|
||||||
|
} else {
|
||||||
|
$pattern_argv = array();
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: We can't use DiffusionLowLevelGitRefQuery here because
|
// NOTE: We can't use DiffusionLowLevelGitRefQuery here because
|
||||||
// `git for-each-ref` does not support `--contains`.
|
// `git for-each-ref` does not support `--contains`.
|
||||||
if ($repository->isWorkingCopyBare()) {
|
if ($repository->isWorkingCopyBare()) {
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
'branch --verbose --no-abbrev --contains %s --',
|
'branch --verbose --no-abbrev --contains %s -- %Ls',
|
||||||
$contains);
|
$contains,
|
||||||
|
$pattern_argv);
|
||||||
$ref_map = DiffusionGitBranch::parseLocalBranchOutput(
|
$ref_map = DiffusionGitBranch::parseLocalBranchOutput(
|
||||||
$stdout);
|
$stdout);
|
||||||
} else {
|
} else {
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
'branch -r --verbose --no-abbrev --contains %s --',
|
'branch -r --verbose --no-abbrev --contains %s -- %Ls',
|
||||||
$contains);
|
$contains,
|
||||||
|
$pattern_argv);
|
||||||
$ref_map = DiffusionGitBranch::parseRemoteBranchOutput(
|
$ref_map = DiffusionGitBranch::parseRemoteBranchOutput(
|
||||||
$stdout,
|
$stdout,
|
||||||
DiffusionGitBranch::DEFAULT_GIT_REMOTE);
|
DiffusionGitBranch::DEFAULT_GIT_REMOTE);
|
||||||
|
|
|
@ -22,6 +22,7 @@ final class DiffusionCommitBranchesController extends DiffusionController {
|
||||||
array(
|
array(
|
||||||
'contains' => $drequest->getCommit(),
|
'contains' => $drequest->getCommit(),
|
||||||
'limit' => $branch_limit + 1,
|
'limit' => $branch_limit + 1,
|
||||||
|
'branch' => null,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
$has_more_branches = (count($branches) > $branch_limit);
|
$has_more_branches = (count($branches) > $branch_limit);
|
||||||
|
|
Loading…
Reference in a new issue