diff options
author | Joey Hess <joey@kitenet.net> | 2014-11-10 15:36:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-11-10 15:36:24 -0400 |
commit | f00d0f9917cd605f27e29ab5d4cfcfc08bdcb3c2 (patch) | |
tree | e6d77b4cf8e5059c2ce01fa17ce70f2fa7d6a990 /Command/PreCommit.hs | |
parent | bf19671a7448479811eb441cdb8a526bbe2b6625 (diff) |
pre-commit: Block partial commit of unlocked annexed file, since that left a typechange staged in index
I had hoped that the git devs could change git's handling of partial
commits to not use a false index file, but seems not.
So, this relies on some git internals to detect that case. The test suite
has a test case added to catch it if changes to git break it.
This commit was sponsored by Paul Tagliamonte.
Diffstat (limited to 'Command/PreCommit.hs')
-rw-r--r-- | Command/PreCommit.hs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Command/PreCommit.hs b/Command/PreCommit.hs index aaaa51fbd..91a972024 100644 --- a/Command/PreCommit.hs +++ b/Command/PreCommit.hs @@ -23,6 +23,8 @@ import Logs.View import Logs.MetaData import Types.View import Types.MetaData +import qualified Git.Index as Git +import qualified Git.LsFiles as Git import qualified Data.Set as S @@ -37,10 +39,18 @@ seek ps = lockPreCommitHook $ ifM isDirect withWords startDirect ps runAnnexHook preCommitAnnexHook , do - -- fix symlinks to files being committed - withFilesToBeCommitted (whenAnnexed Command.Fix.start) ps - -- inject unlocked files into the annex - withFilesUnlockedToBeCommitted startIndirect ps + ifM (liftIO Git.haveFalseIndex) + ( do + (fs, cleanup) <- inRepo $ Git.typeChangedStaged ps + whenM (anyM isUnlocked fs) $ + error "Cannot make a partial commit with unlocked annexed files. You should `git annex add` the files you want to commit, and then run git commit." + void $ liftIO cleanup + , do + -- fix symlinks to files being committed + withFilesToBeCommitted (whenAnnexed Command.Fix.start) ps + -- inject unlocked files into the annex + withFilesUnlockedToBeCommitted startIndirect ps + ) runAnnexHook preCommitAnnexHook -- committing changes to a view updates metadata mv <- currentView |