init: Install working hook scripts when run on a crippled filesystem and on Windows
This commit is contained in:
parent
b36229905f
commit
dc672863c3
4 changed files with 43 additions and 29 deletions
|
@ -13,7 +13,6 @@ module Annex.Hook where
|
||||||
|
|
||||||
import Annex.Common
|
import Annex.Common
|
||||||
import qualified Git.Hook as Git
|
import qualified Git.Hook as Git
|
||||||
import Config
|
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Utility.Shell
|
import Utility.Shell
|
||||||
|
|
||||||
|
@ -57,11 +56,8 @@ mkHookScript s = unlines
|
||||||
]
|
]
|
||||||
|
|
||||||
hookWrite :: Git.Hook -> Annex ()
|
hookWrite :: Git.Hook -> Annex ()
|
||||||
hookWrite h =
|
hookWrite h = unlessM (inRepo $ Git.hookWrite h) $
|
||||||
-- cannot have git hooks in a crippled filesystem (no execute bit)
|
hookWarning h "already exists, not configuring"
|
||||||
unlessM crippledFileSystem $
|
|
||||||
unlessM (inRepo $ Git.hookWrite h) $
|
|
||||||
hookWarning h "already exists, not configuring"
|
|
||||||
|
|
||||||
hookUnWrite :: Git.Hook -> Annex ()
|
hookUnWrite :: Git.Hook -> Annex ()
|
||||||
hookUnWrite h = unlessM (inRepo $ Git.hookUnWrite h) $
|
hookUnWrite h = unlessM (inRepo $ Git.hookUnWrite h) $
|
||||||
|
|
|
@ -23,6 +23,10 @@ git-annex (7.20190731) UNRELEASED; urgency=medium
|
||||||
it applies the same adjustment to the branch before merging it.
|
it applies the same adjustment to the branch before merging it.
|
||||||
* test: Add pass using adjusted unlocked branch.
|
* test: Add pass using adjusted unlocked branch.
|
||||||
* Fix some test suite failures on Windows.
|
* Fix some test suite failures on Windows.
|
||||||
|
* init: Install working hook scripts when run on a crippled filesystem
|
||||||
|
and on Windows. If your repository was set up by an old version
|
||||||
|
of git-annex that omitted the hooks, you can simply re-run git-annex init
|
||||||
|
to install them.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400
|
||||||
|
|
||||||
|
|
15
Git/Hook.hs
15
Git/Hook.hs
|
@ -31,7 +31,18 @@ hookFile :: Hook -> Repo -> FilePath
|
||||||
hookFile h r = localGitDir r </> "hooks" </> hookName h
|
hookFile h r = localGitDir r </> "hooks" </> hookName h
|
||||||
|
|
||||||
{- Writes a hook. Returns False if the hook already exists with a different
|
{- Writes a hook. Returns False if the hook already exists with a different
|
||||||
- content. Upgrades old scripts. -}
|
- content. Upgrades old scripts.
|
||||||
|
-
|
||||||
|
- This can install hooks on both filesystem like FAT that do not support
|
||||||
|
- execute bits, and on Windows.
|
||||||
|
-
|
||||||
|
- If the filesystem does not support execute bits, it's typically mounted
|
||||||
|
- such that all files have the execute bit set. So just write the hook
|
||||||
|
- and ignore failure to make it executable.
|
||||||
|
-
|
||||||
|
- On Windows, git will run hooks that are not executable. The hook
|
||||||
|
- is run with a bundled bash, so should start with #!/bin/sh
|
||||||
|
-}
|
||||||
hookWrite :: Hook -> Repo -> IO Bool
|
hookWrite :: Hook -> Repo -> IO Bool
|
||||||
hookWrite h r = ifM (doesFileExist f)
|
hookWrite h r = ifM (doesFileExist f)
|
||||||
( expectedContent h r >>= \case
|
( expectedContent h r >>= \case
|
||||||
|
@ -45,7 +56,7 @@ hookWrite h r = ifM (doesFileExist f)
|
||||||
go = do
|
go = do
|
||||||
viaTmp writeFile f (hookScript h)
|
viaTmp writeFile f (hookScript h)
|
||||||
p <- getPermissions f
|
p <- getPermissions f
|
||||||
setPermissions f $ p {executable = True}
|
void $ tryIO $ setPermissions f $ p {executable = True}
|
||||||
return True
|
return True
|
||||||
|
|
||||||
{- Removes a hook. Returns False if the hook contained something else, and
|
{- Removes a hook. Returns False if the hook contained something else, and
|
||||||
|
|
|
@ -1,27 +1,30 @@
|
||||||
Two test failures on windows in the import/export tests. The tests fail on
|
Windows test suite fails the import/export tests.
|
||||||
a v7 adjusted unlocked branch, but pass a direct mode. It may be that
|
|
||||||
there's a problem with the tests outside of windows on an adjusted branch.
|
|
||||||
|
|
||||||
The first test fails to export all annexed files to a directory special
|
It imports a file, but the worktree file remains a unlocked pointer
|
||||||
remote.
|
file. So the test fails. Running `git annex smudge--update` fixed the
|
||||||
|
file content.
|
||||||
|
|
||||||
export foo sha1foo failed
|
Reproduced outside the test suite, and tried with GIT_TRACE=1.
|
||||||
|
When `git-annex merge remote/master``runs git merge, it does then smudge
|
||||||
|
--clean the imported files. But smudge --update does not get run. The
|
||||||
|
post-merge hook should run it.
|
||||||
|
|
||||||
No indication of why it failed.
|
Ahh -- on windows, hooks are not written, because the code skips that
|
||||||
|
for a crippled filesystem, assuming it has no execute bit.
|
||||||
|
|
||||||
> Update: Now it shows the problem, which is that the exported file is
|
So, this is both a problem on windows and on crippled filesystems.
|
||||||
> locked so statting it fails. --[[Joey]]
|
The user needs to run smudge --update themselves, or maybe git-annex
|
||||||
|
can do it sometimes. Eg, `git annex merge` (and sync) could certianly
|
||||||
|
smudge --update when on a crippled filesystem. And that would be
|
||||||
|
enough to fix the test suite.
|
||||||
|
|
||||||
The second test fails in an import. It gets as far as updating foo/master,
|
But if a user is on a crippled filesystem with an adjusted branch, and
|
||||||
but then when it tries to merge that branch, there's a merge conflict.
|
they do some other operation that would be covered by post-merge or
|
||||||
That merge conflict seems very likely due to being on an adjusted branch;
|
post-checkout hook, they will be surprised to find unpopulated pointer
|
||||||
foo/master will have the non-adjusted version of the file and merging it
|
files in the working tree.
|
||||||
into a branch where it's been adjusted does sound like there could be a
|
|
||||||
legitimate merge conflict.
|
|
||||||
|
|
||||||
If so, note that the git-annex-import man page suggests doing just such a
|
I think this can be avoided. On eg fat on linux, all files are executable,
|
||||||
merge, so perhaps the docs will need to be updated, if some git-annex
|
so the hook can be installed and will work. On Windows, a hook can start
|
||||||
command is instead used to do the merge. --[[Joey]]
|
with #!/bin/sh and not be executable, and will be run by the bash bundled
|
||||||
|
with git for windows.
|
||||||
> Probably down to only one test failure now after some fixes. Have not
|
--[[Joey]]
|
||||||
> checked. --[[Joey]]
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue