From 4b303197477bca58325c1375850eff9f29e450c8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Mar 2011 11:21:29 -0800 Subject: [PATCH 1/2] Make XHPAST parse-depth warning an actual warning. Summary: XHPAST encounters a parse-depth problem on some files because PHP 5.2 has an un-overridable parse depth limit for JSON. The text of this error says it is a "warning" but we currently raise an error. Make it a warning instead. The JSON depth is 20 until PHP 5.2.3, where it becomes 128. After PHP 5.3 it defaults to 512 and is user-configurable, which will allow us to resolve this issue in nearly all cases. Since I made if/else express as a list in the AST, this only actually arises in long binary chains, most commonly string concatenation, like: $out = 'a'.'a'.'a'.'a'... ...where each string is a variable or HTML tag and the program is constructing a complicated document. At some point I'll add some PHP 5.3 massaging to the XHPAST decoder itself to raise this limit to something more huge. Test Plan: Ran "arc lint --lintall" on a file with a very deep binary expression tree ("1 + 1 + 1 ...") and received a warning instead of an error. Reviewed By: aran Reviewers: pad, aran CC: epriestley, aran Differential Revision: 54 --- src/lint/linter/xhpast/ArcanistXHPASTLinter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php index d642c3cf..fd2f1c8f 100644 --- a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php +++ b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php @@ -79,6 +79,8 @@ class ArcanistXHPASTLinter extends ArcanistLinter { public function getLintSeverityMap() { return array( self::LINT_TODO_COMMENT => ArcanistLintSeverity::SEVERITY_ADVICE, + self::LINT_UNABLE_TO_PARSE + => ArcanistLintSeverity::SEVERITY_WARNING, self::LINT_FORMATTING_CONVENTIONS => ArcanistLintSeverity::SEVERITY_WARNING, self::LINT_NAMING_CONVENTIONS From 71016a09f80a42ceb38a566afc8f33a6d0a85eea Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Mar 2011 15:37:38 -0800 Subject: [PATCH 2/2] Explicitly use "--format=medium" when running 'git log' Summary: Git (the world's hardest revision control system) allows you to change output formats by accident and/or without your direct knowledge. Protect users from themselves. Test Plan: Changed "pretty" in [format] to "format:quack" so every log just outputs the word "quack". Ran "arc diff" successfully. Reviewed By: aran Reviewers: aran CC: epriestley, aran Differential Revision: 56 --- src/repository/api/git/ArcanistGitAPI.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 8d920671..15f5c952 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -119,11 +119,11 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI { $relative = $this->getRelativeCommit(); if ($relative == self::GIT_MAGIC_ROOT_COMMIT) { list($stdout) = execx( - '(cd %s; git log HEAD)', + '(cd %s; git log --format=medium HEAD)', $this->getPath()); } else { list($stdout) = execx( - '(cd %s; git log %s..HEAD)', + '(cd %s; git log --format=medium %s..HEAD)', $this->getPath(), $this->getRelativeCommit()); } @@ -132,7 +132,7 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI { public function getGitHistoryLog() { list($stdout) = execx( - '(cd %s; git log -n%d %s)', + '(cd %s; git log --format=medium -n%d %s)', $this->getPath(), self::SEARCH_LENGTH_FOR_PARENT_REVISIONS, $this->getRelativeCommit());