Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15241267
D21658.id51535.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D21658.id51535.diff
View Options
diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
--- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
@@ -63,48 +63,66 @@
$unresolved = array_fuse($this->refs);
$results = array();
- // First, resolve branches and tags.
- $ref_map = id(new DiffusionLowLevelGitRefQuery())
- ->setRepository($repository)
- ->withRefTypes(
- array(
- PhabricatorRepositoryRefCursor::TYPE_BRANCH,
- PhabricatorRepositoryRefCursor::TYPE_TAG,
- ))
- ->execute();
- $ref_map = mgroup($ref_map, 'getShortName');
-
- $tag_prefix = 'refs/tags/';
+ $possible_symbols = array();
foreach ($unresolved as $ref) {
- if (empty($ref_map[$ref])) {
+
+ // See T13647. If this symbol is exactly 40 hex characters long, it may
+ // never resolve as a branch or tag name. Filter these symbols out for
+ // consistency with Git behavior -- and to avoid an expensive
+ // "git for-each-ref" when resolving only commit hashes, which happens
+ // during repository updates.
+
+ if (preg_match('(^[a-f0-9]{40}\z)', $ref)) {
continue;
}
- foreach ($ref_map[$ref] as $result) {
- $fields = $result->getRawFields();
- $objectname = idx($fields, 'refname');
- if (!strncmp($objectname, $tag_prefix, strlen($tag_prefix))) {
- $type = 'tag';
- } else {
- $type = 'branch';
+ $possible_symbols[$ref] = $ref;
+ }
+
+ // First, resolve branches and tags.
+ if ($possible_symbols) {
+ $ref_map = id(new DiffusionLowLevelGitRefQuery())
+ ->setRepository($repository)
+ ->withRefTypes(
+ array(
+ PhabricatorRepositoryRefCursor::TYPE_BRANCH,
+ PhabricatorRepositoryRefCursor::TYPE_TAG,
+ ))
+ ->execute();
+ $ref_map = mgroup($ref_map, 'getShortName');
+
+ $tag_prefix = 'refs/tags/';
+ foreach ($possible_symbols as $ref) {
+ if (empty($ref_map[$ref])) {
+ continue;
}
- $info = array(
- 'type' => $type,
- 'identifier' => $result->getCommitIdentifier(),
- );
+ foreach ($ref_map[$ref] as $result) {
+ $fields = $result->getRawFields();
+ $objectname = idx($fields, 'refname');
+ if (!strncmp($objectname, $tag_prefix, strlen($tag_prefix))) {
+ $type = 'tag';
+ } else {
+ $type = 'branch';
+ }
+
+ $info = array(
+ 'type' => $type,
+ 'identifier' => $result->getCommitIdentifier(),
+ );
- if ($type == 'tag') {
- $alternate = idx($fields, 'objectname');
- if ($alternate) {
- $info['alternate'] = $alternate;
+ if ($type == 'tag') {
+ $alternate = idx($fields, 'objectname');
+ if ($alternate) {
+ $info['alternate'] = $alternate;
+ }
}
+
+ $results[$ref][] = $info;
}
- $results[$ref][] = $info;
+ unset($unresolved[$ref]);
}
-
- unset($unresolved[$ref]);
}
// If we resolved everything, we're done.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 25, 4:00 PM (20 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7191607
Default Alt Text
D21658.id51535.diff (3 KB)
Attached To
Mode
D21658: Skip "git for-each-ref" when identifying deleted commits
Attached
Detach File
Event Timeline
Log In to Comment