init: When writing hook scripts, set all execute bits, not only the user execute bit
authorJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2020 17:31:12 +0000 (13:31 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 17 Nov 2020 17:31:12 +0000 (13:31 -0400)
CHANGELOG
Git/Hook.hs
doc/bugs/hooks_permissions.mdwn

index 87daf47413f1995b99553d37880e00cb6392e72e..edef6eb3d7f60049a312ff238fe7b0e680b4254c 100644 (file)
--- 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 <id@joeyh.name>  Mon, 16 Nov 2020 09:38:32 -0400
 
index 100111dba6aed84dd602b506dbbc6b9a49fdaec6..45662f2369491c5d9d4ffbece3105cd7dd3d89f9 100644 (file)
@@ -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
index 296c8e2c44ad4069452fe8d3ef416e6440ecbbc8..5c85bb6cd948acccf69f65028fd978be55366c53 100644 (file)
@@ -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]]