From 763a049f74990655982eb781b60577769f8f0b12 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 24 Feb 2014 14:39:44 -0800 Subject: [PATCH] Possibly fix issue where refs engine finds empty refs? Summary: @mbishopim3 reported an issue in IRC: > mbishopim3: epriestley: "Error updating working copy: Commit "" has not been discovered yet! Run discovery before updating refs." any ideas? I can't reproduce it and it went away for him, but one theory is that we're getting here and git/hg are spitting out nothing, which we incorrectly parse as `array("")` when we intend `array()`. Test Plan: Pushed some new commits, ran `bin/repositoy refs X`, got expected results. I can't actually reproduce the bug, but this might fix it and appears to make the code more correct. Reviewers: btrahan Reviewed By: btrahan CC: mbishopim3, aran Differential Revision: https://secure.phabricator.com/D8326 --- .../engine/PhabricatorRepositoryRefEngine.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php index 41092c1030..56826186a1 100644 --- a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php @@ -247,6 +247,11 @@ final class PhabricatorRepositoryRefEngine '{node}\n', hgsprintf('%s', $new_head)); } + + $stdout = trim($stdout); + if (!strlen($stdout)) { + return array(); + } return phutil_split_lines($stdout, $retain_newlines = false); case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: if ($all_closing_heads) { @@ -261,6 +266,11 @@ final class PhabricatorRepositoryRefEngine '%H', $new_head); } + + $stdout = trim($stdout); + if (!strlen($stdout)) { + return array(); + } return phutil_split_lines($stdout, $retain_newlines = false); default: throw new Exception(pht('Unsupported VCS "%s"!', $vcs));