avoid pre-commit hook messing up new-style unlocked files in v6 repo
This commit is contained in:
parent
05b598a057
commit
751120c171
4 changed files with 24 additions and 7 deletions
|
@ -43,6 +43,12 @@ versionSupportsDirectMode = go <$> getVersion
|
||||||
go (Just "6") = False
|
go (Just "6") = False
|
||||||
go _ = True
|
go _ = True
|
||||||
|
|
||||||
|
versionSupportsUnlockedPointers :: Annex Bool
|
||||||
|
versionSupportsUnlockedPointers = go <$> getVersion
|
||||||
|
where
|
||||||
|
go (Just "6") = True
|
||||||
|
go _ = False
|
||||||
|
|
||||||
setVersion :: Version -> Annex ()
|
setVersion :: Version -> Annex ()
|
||||||
setVersion = setConfig versionField
|
setVersion = setConfig versionField
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ withPairs a params = seekActions $ return $ map a $ pairs [] params
|
||||||
pairs c (x:y:xs) = pairs ((x,y):c) xs
|
pairs c (x:y:xs) = pairs ((x,y):c) xs
|
||||||
pairs _ _ = error "expected pairs"
|
pairs _ _ = error "expected pairs"
|
||||||
|
|
||||||
withFilesToBeCommitted :: (String -> CommandStart) -> CmdParams -> CommandSeek
|
withFilesToBeCommitted :: (FilePath -> CommandStart) -> CmdParams -> CommandSeek
|
||||||
withFilesToBeCommitted a params = seekActions $ prepFiltered a $
|
withFilesToBeCommitted a params = seekActions $ prepFiltered a $
|
||||||
seekHelper LsFiles.stagedNotDeleted params
|
seekHelper LsFiles.stagedNotDeleted params
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@ import qualified Command.Add
|
||||||
import qualified Command.Fix
|
import qualified Command.Fix
|
||||||
import Annex.Direct
|
import Annex.Direct
|
||||||
import Annex.Hook
|
import Annex.Hook
|
||||||
|
import Annex.Link
|
||||||
import Annex.View
|
import Annex.View
|
||||||
|
import Annex.Version
|
||||||
import Annex.View.ViewedFile
|
import Annex.View.ViewedFile
|
||||||
import Annex.LockFile
|
import Annex.LockFile
|
||||||
import Logs.View
|
import Logs.View
|
||||||
|
@ -49,9 +51,14 @@ seek ps = lockPreCommitHook $ ifM isDirect
|
||||||
void $ liftIO cleanup
|
void $ liftIO cleanup
|
||||||
, do
|
, do
|
||||||
-- fix symlinks to files being committed
|
-- fix symlinks to files being committed
|
||||||
withFilesToBeCommitted (whenAnnexed Command.Fix.start) ps
|
flip withFilesToBeCommitted ps $ \f ->
|
||||||
|
maybe stop (Command.Fix.start f)
|
||||||
|
=<< isAnnexLink f
|
||||||
-- inject unlocked files into the annex
|
-- inject unlocked files into the annex
|
||||||
withFilesUnlockedToBeCommitted startIndirect ps
|
-- (not needed when repo version uses
|
||||||
|
-- unlocked pointer files)
|
||||||
|
unlessM versionSupportsUnlockedPointers $
|
||||||
|
withFilesUnlockedToBeCommitted startInjectUnlocked ps
|
||||||
)
|
)
|
||||||
runAnnexHook preCommitAnnexHook
|
runAnnexHook preCommitAnnexHook
|
||||||
-- committing changes to a view updates metadata
|
-- committing changes to a view updates metadata
|
||||||
|
@ -64,8 +71,8 @@ seek ps = lockPreCommitHook $ ifM isDirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
startIndirect :: FilePath -> CommandStart
|
startInjectUnlocked :: FilePath -> CommandStart
|
||||||
startIndirect f = next $ do
|
startInjectUnlocked f = next $ do
|
||||||
unlessM (callCommandAction $ Command.Add.start f) $
|
unlessM (callCommandAction $ Command.Add.start f) $
|
||||||
error $ "failed to add " ++ f ++ "; canceling commit"
|
error $ "failed to add " ++ f ++ "; canceling commit"
|
||||||
next $ return True
|
next $ return True
|
||||||
|
|
|
@ -12,10 +12,14 @@ This is meant to be called from git's pre-commit hook. `git annex init`
|
||||||
automatically creates a pre-commit hook using this.
|
automatically creates a pre-commit hook using this.
|
||||||
|
|
||||||
Fixes up symlinks that are staged as part of a commit, to ensure they
|
Fixes up symlinks that are staged as part of a commit, to ensure they
|
||||||
point to annexed content. Also handles injecting changes to unlocked
|
point to annexed content.
|
||||||
files into the annex. When in a view, updates metadata to reflect changes
|
|
||||||
|
When in a view, updates metadata to reflect changes
|
||||||
made to files in the view.
|
made to files in the view.
|
||||||
|
|
||||||
|
When in a repository that has not been upgraded to annex.version 6,
|
||||||
|
also handles injecting changes to unlocked files into the annex.
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
[[git-annex]](1)
|
[[git-annex]](1)
|
||||||
|
|
Loading…
Reference in a new issue