From 74faacee4d4a96ac8be124ea1c913cb37b36820a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 5 May 2014 10:54:53 -0700 Subject: [PATCH] Never try to run README as a commit hook Summary: Fixes T4960. Users `chmod +x` this, and then bash chokes on it. Phabricator "owns" this file anyway, so there is no real ambiguity here: this should never be a hook script. Test Plan: - Did `chmod +x README`. - Made a commit. - Added `z.sh`, got blocked. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T4960 Differential Revision: https://secure.phabricator.com/D8981 --- .../diffusion/engine/DiffusionCommitHookEngine.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index 4d39a71385..27842f7d94 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -637,9 +637,19 @@ final class DiffusionCommitHookEngine extends Phobject { foreach (Filesystem::listDirectory($directory) as $path) { $full_path = $directory.DIRECTORY_SEPARATOR.$path; - if (is_executable($full_path)) { - $executables[] = $full_path; + if (!is_executable($full_path)) { + // Don't include non-executable files. + continue; } + + if (basename($full_path) == 'README') { + // Don't include README, even if it is marked as executable. It almost + // certainly got caught in the crossfire of a sweeping `chmod`, since + // users do this with some frequency. + continue; + } + + $executables[] = $full_path; } return $executables;