From 6b63278f31095e1042a6a14494beab29e585033b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 17 Nov 2020 13:31:12 -0400 Subject: [PATCH] init: When writing hook scripts, set all execute bits, not only the user execute bit --- CHANGELOG | 2 ++ Git/Hook.hs | 5 +++-- doc/bugs/hooks_permissions.mdwn | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 87daf47413..edef6eb3d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,8 @@ git-annex (8.20201117) UNRELEASED; urgency=medium branches set up by git-annex adjust --unlock-present/--hide-missing. * examinekey: Added a "file" format variable for consistency with find, and for easier scripting. + * init: When writing hook scripts, set all execute bits, not only + the user execute bit. -- Joey Hess Mon, 16 Nov 2020 09:38:32 -0400 diff --git a/Git/Hook.hs b/Git/Hook.hs index 100111dba6..45662f2369 100644 --- a/Git/Hook.hs +++ b/Git/Hook.hs @@ -55,8 +55,9 @@ hookWrite h r = ifM (doesFileExist f) f = hookFile h r go = do viaTmp writeFile f (hookScript h) - p <- getPermissions f - void $ tryIO $ setPermissions f $ p {executable = True} + void $ tryIO $ modifyFileMode + (toRawFilePath f) + (addModes executeModes) return True {- Removes a hook. Returns False if the hook contained something else, and diff --git a/doc/bugs/hooks_permissions.mdwn b/doc/bugs/hooks_permissions.mdwn index 296c8e2c44..5c85bb6cd9 100644 --- a/doc/bugs/hooks_permissions.mdwn +++ b/doc/bugs/hooks_permissions.mdwn @@ -20,3 +20,13 @@ git-annex version: 8.20201103, on Debian sid ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) git-annex is super great :-) + +> That's a bug indeed! I've fixed it. +> +> I decided to not make re-running `git-annex init` fix up the file mode +> if the hook already existed with the wrong permissions. +> That seemed like probably a bad idea, because it's at least possible +> the user might intend to unset one of the x bits and git-annex should not +> get in the way of that. So, you should `chmod a+x` the hooks yourself. +> +> [[done]] --[[Joey]]