From 52462a46c00cecfbb6c4235e203b923f136e86f9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 9 Dec 2013 13:22:13 -0800 Subject: [PATCH] Raise a better error for malformed `git ls-tree` Summary: Ref T4159. See T4159 for discussion. Test Plan: Faked the error and generated a reasonable error message. Reviewers: hach-que, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4159 Differential Revision: https://secure.phabricator.com/D7744 --- .../conduit/ConduitAPI_diffusion_browsequery_Method.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php index b000584cfe..0066e68333 100644 --- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php @@ -100,6 +100,15 @@ final class ConduitAPI_diffusion_browsequery_Method $results = array(); foreach (explode("\0", rtrim($stdout)) as $line) { + if (substr_count($line, ' ') < 4) { + throw new Exception( + pht( + 'Expected " ", for ls-tree of '. + '"%s:%s", got: %s', + $commit, + $path, + $line)); + } // NOTE: Limit to 5 components so we parse filenames with spaces in them // correctly.