summaryrefslogtreecommitdiff
path: root/Command/PreCommit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-09 15:18:25 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-09 15:18:54 -0400
commit855c0dd645f53da3ad10320605ef4e5e6276305b (patch)
tree33835a3172dd5f21c2b1c07a6ae087a55a8195d5 /Command/PreCommit.hs
parent819e710ac27f0e50a83eb5f2036b5c4a041c882c (diff)
avoid pre-commit hook messing up new-style unlocked files in v6 repo
Diffstat (limited to 'Command/PreCommit.hs')
-rw-r--r--Command/PreCommit.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs
index 2d62b51f3..b6f52d01c 100644
--- a/Command/PreCommit.hs
+++ b/Command/PreCommit.hs
@@ -16,7 +16,9 @@ import qualified Command.Add
import qualified Command.Fix
import Annex.Direct
import Annex.Hook
+import Annex.Link
import Annex.View
+import Annex.Version
import Annex.View.ViewedFile
import Annex.LockFile
import Logs.View
@@ -49,9 +51,14 @@ seek ps = lockPreCommitHook $ ifM isDirect
void $ liftIO cleanup
, do
-- 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
- withFilesUnlockedToBeCommitted startIndirect ps
+ -- (not needed when repo version uses
+ -- unlocked pointer files)
+ unlessM versionSupportsUnlockedPointers $
+ withFilesUnlockedToBeCommitted startInjectUnlocked ps
)
runAnnexHook preCommitAnnexHook
-- committing changes to a view updates metadata
@@ -64,8 +71,8 @@ seek ps = lockPreCommitHook $ ifM isDirect
)
-startIndirect :: FilePath -> CommandStart
-startIndirect f = next $ do
+startInjectUnlocked :: FilePath -> CommandStart
+startInjectUnlocked f = next $ do
unlessM (callCommandAction $ Command.Add.start f) $
error $ "failed to add " ++ f ++ "; canceling commit"
next $ return True