summaryrefslogtreecommitdiff
path: root/Command/Uninit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-16 15:00:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-16 15:00:25 -0400
commitee55dd4a57a2bc7026ea56cd71a55ee73919a16f (patch)
tree3bb5138028d2d605f84267160ed80c8a3c890b20 /Command/Uninit.hs
parentb16c208e0358c883470c88456c9fa527663c1d55 (diff)
uninit: Preserve .git/annex/objects at the end, if it still has content, so that old versions of files and deleted files are not deleted. Print a message with some suggested actions.
Diffstat (limited to 'Command/Uninit.hs')
-rw-r--r--Command/Uninit.hs23
1 files changed, 21 insertions, 2 deletions
diff --git a/Command/Uninit.hs b/Command/Uninit.hs
index c57fff017..066440449 100644
--- a/Command/Uninit.hs
+++ b/Command/Uninit.hs
@@ -62,9 +62,28 @@ startUnannex file info = do
start :: CommandStart
start = next $ next $ do
annexdir <- fromRepo gitAnnexDir
+ annexobjectdir <- fromRepo gitAnnexObjectDir
+ present <- getKeysPresent
+ if null present
+ then liftIO $ removeDirectoryRecursive annexdir
+ else error $ unlines
+ [ "Not fully uninitialized"
+ , "Some annexed data is still left in " ++ annexobjectdir
+ , "This may include deleted files, or old versions of modified files."
+ , ""
+ , "If you don't care about preserving the data, just delete the"
+ , "directory."
+ , ""
+ , "Or, you can move it to another location, in case it turns out"
+ , "something in there is important."
+ , ""
+ , "Or, you can run `git annex unused` followed by `git annex dropunused`"
+ , "to remove data that is not used by any tag or branch, which might"
+ , "take care of all the data."
+ , ""
+ , "Then run `git annex uninit` again to finish."
+ ]
uninitialize
- mapM_ removeAnnex =<< getKeysPresent
- liftIO $ removeDirectoryRecursive annexdir
-- avoid normal shutdown
saveState False
inRepo $ Git.Command.run