Changeset View
Changeset View
Standalone View
Standalone View
src/repository/marker/ArcanistGitRepositoryMarkerQuery.php
Context not available. | |||||
$expect_count = count($field_list); | $expect_count = count($field_list); | ||||
$branch_prefix = 'refs/heads/'; | $branch_prefix = 'refs/heads/'; | ||||
$branch_length = strlen($branch_prefix); | $branch_length = @strlen($branch_prefix); | ||||
$remote_prefix = 'refs/remotes/'; | $remote_prefix = 'refs/remotes/'; | ||||
$remote_length = strlen($remote_prefix); | $remote_length = @strlen($remote_prefix); | ||||
list($stdout) = $api->newFuture( | list($stdout) = $api->newFuture( | ||||
'for-each-ref --format %s -- refs/', | 'for-each-ref --format %s -- refs/', | ||||
Context not available. | |||||
$markers = array(); | $markers = array(); | ||||
$lines = explode("\2", $stdout); | $lines = @explode("\2", $stdout); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
$line = trim($line); | $line = trim($line); | ||||
if (!strlen($line)) { | if (!@strlen($line)) { | ||||
continue; | continue; | ||||
} | } | ||||
$fields = explode("\1", $line, $expect_count); | $fields = @explode("\1", $line, $expect_count); | ||||
$actual_count = count($fields); | $actual_count = count($fields); | ||||
if ($actual_count !== $expect_count) { | if ($actual_count !== $expect_count) { | ||||
throw new Exception( | throw new Exception( | ||||
Context not available. | |||||
if (!strncmp($ref, $branch_prefix, $branch_length)) { | if (!strncmp($ref, $branch_prefix, $branch_length)) { | ||||
$type = ArcanistMarkerRef::TYPE_BRANCH; | $type = ArcanistMarkerRef::TYPE_BRANCH; | ||||
$name = substr($ref, $branch_length); | $name = @substr($ref, $branch_length); | ||||
} else if (!strncmp($ref, $remote_prefix, $remote_length)) { | } else if (!strncmp($ref, $remote_prefix, $remote_length)) { | ||||
// This isn't entirely correct: the ref may be a tag, etc. | // This isn't entirely correct: the ref may be a tag, etc. | ||||
$type = ArcanistMarkerRef::TYPE_BRANCH; | $type = ArcanistMarkerRef::TYPE_BRANCH; | ||||
$label = substr($ref, $remote_length); | $label = @substr($ref, $remote_length); | ||||
$parts = explode('/', $label, 2); | $parts = @explode('/', $label, 2); | ||||
$remote_name = $parts[0]; | $remote_name = $parts[0]; | ||||
$name = $parts[1]; | $name = $parts[1]; | ||||
Context not available. | |||||
$marker->setRemoteName($remote_name); | $marker->setRemoteName($remote_name); | ||||
} | } | ||||
if (strlen($dst_hash)) { | if (@strlen($dst_hash)) { | ||||
$commit_hash = $dst_hash; | $commit_hash = $dst_hash; | ||||
} else { | } else { | ||||
$commit_hash = $hash; | $commit_hash = $hash; | ||||
Context not available. | |||||
} | } | ||||
$matches = null; | $matches = null; | ||||
if (!preg_match('(^refs/heads/(.*)\z)', trim($stdout), $matches)) { | if (!@preg_match('(^refs/heads/(.*)\z)', trim($stdout), $matches)) { | ||||
return null; | return null; | ||||
} | } | ||||
Context not available. | |||||
list($stdout) = $future->resolve(); | list($stdout) = $future->resolve(); | ||||
$branch_prefix = 'refs/heads/'; | $branch_prefix = 'refs/heads/'; | ||||
$branch_length = strlen($branch_prefix); | $branch_length = @strlen($branch_prefix); | ||||
$pattern = '(^(?P<hash>\S+)\t(?P<ref>\S+)\z)'; | $pattern = '(^(?P<hash>\S+)\t(?P<ref>\S+)\z)'; | ||||
$markers = array(); | $markers = array(); | ||||
Context not available. | |||||
$lines = phutil_split_lines($stdout, false); | $lines = phutil_split_lines($stdout, false); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
$matches = null; | $matches = null; | ||||
$ok = preg_match($pattern, $line, $matches); | $ok = @preg_match($pattern, $line, $matches); | ||||
if (!$ok) { | if (!$ok) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
Context not available. | |||||
if (!strncmp($ref, $branch_prefix, $branch_length)) { | if (!strncmp($ref, $branch_prefix, $branch_length)) { | ||||
$type = ArcanistMarkerRef::TYPE_BRANCH; | $type = ArcanistMarkerRef::TYPE_BRANCH; | ||||
$name = substr($ref, $branch_length); | $name = @substr($ref, $branch_length); | ||||
} else { | } else { | ||||
// For now, discard other refs. | // For now, discard other refs. | ||||
continue; | continue; | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0