From 85c953ebe4a6fef332158fd757d97c5a58682d3a Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 17 May 2022 16:15:03 -0700 Subject: [PATCH] Fix a PHP 8.1 repository marker issue in Mercurial Summary: Ref T13588. "arc-ls-markers" emits a "branch-state" marker so callers can identify which branch is active in the working copy. This marker doesn't have an associated commit, so trying to generate a display name fails under stricter PHP 8.1 rules when we try to `substr(null, ...)`. Don't attempt to generate a display name for markers with no commit hash. Test Plan: - Ran `arc branches` under PHP 8.1 in a Mercurial repository. - Before: fatal. - After: sensible output. Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21825 --- src/repository/marker/ArcanistRepositoryMarkerQuery.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/repository/marker/ArcanistRepositoryMarkerQuery.php b/src/repository/marker/ArcanistRepositoryMarkerQuery.php index e72ea78f..74e1cdf8 100644 --- a/src/repository/marker/ArcanistRepositoryMarkerQuery.php +++ b/src/repository/marker/ArcanistRepositoryMarkerQuery.php @@ -64,8 +64,10 @@ abstract class ArcanistRepositoryMarkerQuery $marker->attachWorkingCopyStateRef($state_ref); $hash = $marker->getCommitHash(); - $hash = $api->getDisplayHash($hash); - $marker->setDisplayHash($hash); + if ($hash !== null) { + $hash = $api->getDisplayHash($hash); + $marker->setDisplayHash($hash); + } } $types = $this->markerTypes;