summaryrefslogtreecommitdiff
path: root/Command/Uninit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-22 11:54:50 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-22 11:54:50 -0400
commitf8ba6b3bb853f63421f4117abb3f8fe1b071c7ef (patch)
treecf437db8f33b3fe31269d73ae4e768dfe48061e6 /Command/Uninit.hs
parentaec14e8e2e1b69a8fc37f509b6d3a36b2cde1736 (diff)
uninit: Check and abort if there are symlinks to annexed content that are not checked into git.
Diffstat (limited to 'Command/Uninit.hs')
-rw-r--r--Command/Uninit.hs23
1 files changed, 15 insertions, 8 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index 6ac3e1216..8b653da7d 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -36,7 +36,20 @@ check = do
[Params "rev-parse --abbrev-ref HEAD"]
seek :: [CommandSeek]
-seek = [withFilesInGit $ whenAnnexed startUnannex, withNothing start]
+seek = [
+ withFilesNotInGit $ whenAnnexed startCheckIncomplete,
+ withFilesInGit $ whenAnnexed startUnannex
+ , withNothing start
+ ]
+
+{- git annex symlinks that are not checked into git could be left by an
+ - interrupted add. -}
+startCheckIncomplete :: FilePath -> (Key, Backend) -> CommandStart
+startCheckIncomplete file _ = error $ unlines
+ [ file ++ " points to annexed content, but is not checked into git."
+ , "Perhaps this was left behind by an interrupted git annex add?"
+ , "Not continuing with uninit; either delete or git annex add the file and retry."
+ ]
startUnannex :: FilePath -> (Key, Backend) -> CommandStart
startUnannex file info = do
@@ -47,13 +60,7 @@ startUnannex file info = do
Command.Unannex.start file info
start :: CommandStart
-start = next perform
-
-perform :: CommandPerform
-perform = next cleanup
-
-cleanup :: CommandCleanup
-cleanup = do
+start = next $ next $ do
annexdir <- fromRepo gitAnnexDir
uninitialize
mapM_ removeAnnex =<< getKeysPresent