summaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-14 12:17:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-14 12:17:38 -0400
commit95a1f6b2accca9b7c6a6c30c92380dc0de57d3a0 (patch)
treed73c1e57eb5ee1fbb2f64869092716386d899db7 /Git.hs
parentcaf97fcffd0a1e934fef60c0cae878ee3813f81f (diff)
check hook executability
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Git.hs b/Git.hs
index 043cda5ea..9b7dccfeb 100644
--- a/Git.hs
+++ b/Git.hs
@@ -32,9 +32,11 @@ import qualified Data.Map as M
import Data.Char
import Network.URI (uriPath, uriScheme, unEscapeString)
import System.Directory
+import System.Posix.Files
import Common
import Git.Types
+import Utility.FileMode
{- User-visible description of a git repo. -}
repoDescribe :: Repo -> String
@@ -111,8 +113,12 @@ gitDir repo
hookPath :: String -> Repo -> IO (Maybe FilePath)
hookPath script repo = do
let hook = gitDir repo </> "hooks" </> script
- ok <- doesFileExist hook
- return $ if ok then Just hook else Nothing
+ e <- doesFileExist hook
+ if e
+ then do
+ m <- fileMode <$> getFileStatus hook
+ return $ if isExecutable m then Just hook else Nothing
+ else return Nothing
{- Path to a repository's --work-tree, that is, its top.
-